LMs // Use LMInstantiator to print loading statistics.
This commit is contained in:
parent
3bd8fa1ea7
commit
3260101b2f
|
@ -109,6 +109,10 @@ extension vChewing {
|
|||
if FileManager.default.isReadableFile(atPath: path) {
|
||||
lmCore.close()
|
||||
lmCore.open(path)
|
||||
IME.prtDebugIntel("lmCore: \(lmCore.count) entries of data loaded from: \(path)")
|
||||
if path.contains("vChewing/") {
|
||||
lmCore.dump()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,6 +121,10 @@ extension vChewing {
|
|||
if FileManager.default.isReadableFile(atPath: path) {
|
||||
lmCNS.close()
|
||||
lmCNS.open(path)
|
||||
IME.prtDebugIntel("lmCNS: \(lmCNS.count) entries of data loaded from: \(path)")
|
||||
if path.contains("vChewing/") {
|
||||
lmCNS.dump()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,6 +133,10 @@ extension vChewing {
|
|||
if FileManager.default.isReadableFile(atPath: path) {
|
||||
lmMisc.close()
|
||||
lmMisc.open(path)
|
||||
IME.prtDebugIntel("lmMisc: \(lmMisc.count) entries of data loaded from: \(path)")
|
||||
if path.contains("vChewing/") {
|
||||
lmMisc.dump()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,6 +145,10 @@ extension vChewing {
|
|||
if FileManager.default.isReadableFile(atPath: path) {
|
||||
lmSymbols.close()
|
||||
lmSymbols.open(path)
|
||||
IME.prtDebugIntel("lmSymbol: \(lmSymbols.count) entries of data loaded from: \(path)")
|
||||
if path.contains("vChewing/") {
|
||||
lmSymbols.dump()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,10 +156,18 @@ extension vChewing {
|
|||
if FileManager.default.isReadableFile(atPath: path) {
|
||||
lmUserPhrases.close()
|
||||
lmUserPhrases.open(path)
|
||||
IME.prtDebugIntel("lmUserPhrases: \(lmUserPhrases.count) entries of data loaded from: \(path)")
|
||||
if path.contains("vChewing/") {
|
||||
lmUserPhrases.dump()
|
||||
}
|
||||
}
|
||||
if FileManager.default.isReadableFile(atPath: filterPath) {
|
||||
lmFiltered.close()
|
||||
lmFiltered.open(filterPath)
|
||||
IME.prtDebugIntel("lmFiltered: \(lmFiltered.count) entries of data loaded from: \(path)")
|
||||
if path.contains("vChewing/") {
|
||||
lmFiltered.dump()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,6 +175,10 @@ extension vChewing {
|
|||
if FileManager.default.isReadableFile(atPath: path) {
|
||||
lmUserSymbols.close()
|
||||
lmUserSymbols.open(path)
|
||||
IME.prtDebugIntel("lmUserSymbol: \(lmUserSymbols.count) entries of data loaded from: \(path)")
|
||||
if path.contains("vChewing/") {
|
||||
lmUserSymbols.dump()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,6 +186,10 @@ extension vChewing {
|
|||
if FileManager.default.isReadableFile(atPath: path) {
|
||||
lmAssociates.close()
|
||||
lmAssociates.open(path)
|
||||
IME.prtDebugIntel("lmAssociates: \(lmAssociates.count) entries of data loaded from: \(path)")
|
||||
if path.contains("vChewing/") {
|
||||
lmAssociates.dump()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,6 +197,10 @@ extension vChewing {
|
|||
if FileManager.default.isReadableFile(atPath: path) {
|
||||
lmReplacements.close()
|
||||
lmReplacements.open(path)
|
||||
IME.prtDebugIntel("lmReplacements: \(lmReplacements.count) entries of data loaded from: \(path)")
|
||||
if path.contains("vChewing/") {
|
||||
lmReplacements.dump()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,6 @@ extension vChewing {
|
|||
keyValueMap[currentKV.key, default: []].append(currentKV)
|
||||
}
|
||||
}
|
||||
IME.prtDebugIntel("\(count) entries of data loaded from: \(path)")
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -91,6 +90,18 @@ extension vChewing {
|
|||
}
|
||||
}
|
||||
|
||||
public func dump() {
|
||||
var strDump = ""
|
||||
for entry in keyValueMap {
|
||||
let rows: [Megrez.KeyValuePair] = entry.value
|
||||
for row in rows {
|
||||
let addline = row.key + " " + row.value + "\n"
|
||||
strDump += addline
|
||||
}
|
||||
}
|
||||
IME.prtDebugIntel(strDump)
|
||||
}
|
||||
|
||||
public func valuesFor(key: String) -> [String]? {
|
||||
var v: [String] = []
|
||||
if let matched = keyValueMap[key] {
|
||||
|
|
|
@ -115,7 +115,6 @@ extension vChewing {
|
|||
keyValueScoreMap[key, default: []].append(currentUnigram)
|
||||
}
|
||||
}
|
||||
IME.prtDebugIntel("\(count) entries of data loaded from: \(path)")
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -130,7 +129,7 @@ extension vChewing {
|
|||
public func dump() {
|
||||
var strDump = ""
|
||||
for entry in keyValueScoreMap {
|
||||
let rows: [Megrez.Unigram] = entry.1
|
||||
let rows: [Megrez.Unigram] = entry.value
|
||||
for row in rows {
|
||||
let addline = row.keyValue.key + " " + row.keyValue.value + " " + String(row.score) + "\n"
|
||||
strDump += addline
|
||||
|
|
|
@ -46,6 +46,7 @@ extension vChewing {
|
|||
|
||||
@discardableResult public mutating func open(_ path: String) -> Bool {
|
||||
if isLoaded() {
|
||||
IME.prtDebugIntel("Not loading this one due to isLoaded result of true: \(path)")
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -85,10 +86,6 @@ extension vChewing {
|
|||
keyValueMap[currentKV.key, default: []].append(currentKV)
|
||||
}
|
||||
}
|
||||
IME.prtDebugIntel("\(count) entries of data loaded from: \(path)")
|
||||
if path.contains("vChewing/") {
|
||||
dump()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -101,7 +98,7 @@ extension vChewing {
|
|||
public func dump() {
|
||||
var strDump = ""
|
||||
for entry in keyValueMap {
|
||||
let rows: [Megrez.KeyValuePair] = entry.1
|
||||
let rows: [Megrez.KeyValuePair] = entry.value
|
||||
for row in rows {
|
||||
let addline = row.key + " " + row.value + "\n"
|
||||
strDump += addline
|
||||
|
|
|
@ -82,7 +82,6 @@ extension vChewing {
|
|||
keyValueMap[currentKV.key] = currentKV.value
|
||||
}
|
||||
}
|
||||
IME.prtDebugIntel("\(count) entries of data loaded from: \(path)")
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -92,6 +91,14 @@ extension vChewing {
|
|||
}
|
||||
}
|
||||
|
||||
public func dump() {
|
||||
var strDump = ""
|
||||
for entry in keyValueMap {
|
||||
strDump += entry.key + " " + entry.value + "\n"
|
||||
}
|
||||
IME.prtDebugIntel(strDump)
|
||||
}
|
||||
|
||||
public func valuesFor(key: String) -> String {
|
||||
keyValueMap[key] ?? ""
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue