LMs // Clang-format.
This commit is contained in:
parent
c49020097e
commit
2f4c993e3f
|
@ -44,7 +44,7 @@ extension vChewing {
|
||||||
!keyValueMap.isEmpty
|
!keyValueMap.isEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult mutating public func open(_ path: String) -> Bool {
|
@discardableResult public mutating func open(_ path: String) -> Bool {
|
||||||
if isLoaded() {
|
if isLoaded() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -91,12 +91,12 @@ extension vChewing {
|
||||||
keyValueMap[currentKV.key, default: []].append(currentKV)
|
keyValueMap[currentKV.key, default: []].append(currentKV)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IME.prtDebugIntel("\(self.keyValueMap.count) entries of data loaded from: \(path)")
|
IME.prtDebugIntel("\(keyValueMap.count) entries of data loaded from: \(path)")
|
||||||
theData = ""
|
theData = ""
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
mutating public func close() {
|
public mutating func close() {
|
||||||
if isLoaded() {
|
if isLoaded() {
|
||||||
keyValueMap.removeAll()
|
keyValueMap.removeAll()
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ extension vChewing {
|
||||||
!keyValueScoreMap.isEmpty
|
!keyValueScoreMap.isEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult mutating public func open(_ path: String) -> Bool {
|
@discardableResult public mutating func open(_ path: String) -> Bool {
|
||||||
if isLoaded() {
|
if isLoaded() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ extension vChewing {
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
var currentUnigram = Megrez.Unigram(keyValue: Megrez.KeyValuePair(), score: self.defaultScore)
|
var currentUnigram = Megrez.Unigram(keyValue: Megrez.KeyValuePair(), score: defaultScore)
|
||||||
var columnOne = ""
|
var columnOne = ""
|
||||||
var columnTwo = ""
|
var columnTwo = ""
|
||||||
for (unitID, unitContent) in lineContent.components(separatedBy: " ").enumerated() {
|
for (unitID, unitContent) in lineContent.components(separatedBy: " ").enumerated() {
|
||||||
|
@ -102,7 +102,7 @@ extension vChewing {
|
||||||
case 1:
|
case 1:
|
||||||
columnTwo = unitContent
|
columnTwo = unitContent
|
||||||
case 2:
|
case 2:
|
||||||
if !self.shouldForceDefaultScore {
|
if !shouldForceDefaultScore {
|
||||||
if let unitContentConverted = Double(unitContent) {
|
if let unitContentConverted = Double(unitContent) {
|
||||||
currentUnigram.score = unitContentConverted
|
currentUnigram.score = unitContentConverted
|
||||||
} else {
|
} else {
|
||||||
|
@ -117,20 +117,20 @@ extension vChewing {
|
||||||
currentUnigram.score -= (Double(lineID) * 0.000001)
|
currentUnigram.score -= (Double(lineID) * 0.000001)
|
||||||
}
|
}
|
||||||
let kvPair =
|
let kvPair =
|
||||||
self.shouldReverse
|
shouldReverse
|
||||||
? Megrez.KeyValuePair(key: columnTwo, value: columnOne)
|
? Megrez.KeyValuePair(key: columnTwo, value: columnOne)
|
||||||
: Megrez.KeyValuePair(key: columnOne, value: columnTwo)
|
: Megrez.KeyValuePair(key: columnOne, value: columnTwo)
|
||||||
currentUnigram.keyValue = kvPair
|
currentUnigram.keyValue = kvPair
|
||||||
let key = self.shouldReverse ? columnTwo : columnOne
|
let key = shouldReverse ? columnTwo : columnOne
|
||||||
self.keyValueScoreMap[key, default: []].append(currentUnigram)
|
keyValueScoreMap[key, default: []].append(currentUnigram)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IME.prtDebugIntel("\(self.keyValueScoreMap.count) entries of data loaded from: \(path)")
|
IME.prtDebugIntel("\(keyValueScoreMap.count) entries of data loaded from: \(path)")
|
||||||
theData = ""
|
theData = ""
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
mutating public func close() {
|
public mutating func close() {
|
||||||
if isLoaded() {
|
if isLoaded() {
|
||||||
keyValueScoreMap.removeAll()
|
keyValueScoreMap.removeAll()
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ extension vChewing {
|
||||||
!keyValueMap.isEmpty
|
!keyValueMap.isEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult mutating public func open(_ path: String) -> Bool {
|
@discardableResult public mutating func open(_ path: String) -> Bool {
|
||||||
if isLoaded() {
|
if isLoaded() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ extension vChewing {
|
||||||
keyValueMap[currentKV.key, default: []].append(currentKV)
|
keyValueMap[currentKV.key, default: []].append(currentKV)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IME.prtDebugIntel("\(self.keyValueMap.count) entries of data loaded from: \(path)")
|
IME.prtDebugIntel("\(keyValueMap.count) entries of data loaded from: \(path)")
|
||||||
theData = ""
|
theData = ""
|
||||||
if path.contains("vChewing/") {
|
if path.contains("vChewing/") {
|
||||||
dump()
|
dump()
|
||||||
|
@ -103,7 +103,7 @@ extension vChewing {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
mutating public func close() {
|
public mutating func close() {
|
||||||
if isLoaded() {
|
if isLoaded() {
|
||||||
keyValueMap.removeAll()
|
keyValueMap.removeAll()
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ extension vChewing {
|
||||||
!keyValueMap.isEmpty
|
!keyValueMap.isEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult mutating public func open(_ path: String) -> Bool {
|
@discardableResult public mutating func open(_ path: String) -> Bool {
|
||||||
if isLoaded() {
|
if isLoaded() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -91,12 +91,12 @@ extension vChewing {
|
||||||
keyValueMap[currentKV.key] = currentKV.value
|
keyValueMap[currentKV.key] = currentKV.value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IME.prtDebugIntel("\(self.keyValueMap.count) entries of data loaded from: \(path)")
|
IME.prtDebugIntel("\(keyValueMap.count) entries of data loaded from: \(path)")
|
||||||
theData = ""
|
theData = ""
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
mutating public func close() {
|
public mutating func close() {
|
||||||
if isLoaded() {
|
if isLoaded() {
|
||||||
keyValueMap.removeAll()
|
keyValueMap.removeAll()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue