mgrLangModel // Fix wrong path assignments.

This commit is contained in:
ShikiSuen 2022-05-04 15:57:13 +08:00
parent 5d39a03d8d
commit fe3659011f
3 changed files with 26 additions and 4 deletions

View File

@ -98,6 +98,8 @@ extension vChewing {
if path.contains("vChewing/") { if path.contains("vChewing/") {
lmCore.dump() lmCore.dump()
} }
} else {
IME.prtDebugIntel("lmCore: File access failure: \(path)")
} }
} }
@ -109,6 +111,8 @@ extension vChewing {
if path.contains("vChewing/") { if path.contains("vChewing/") {
lmCNS.dump() lmCNS.dump()
} }
} else {
IME.prtDebugIntel("lmCNS: File access failure: \(path)")
} }
} }
@ -120,6 +124,8 @@ extension vChewing {
if path.contains("vChewing/") { if path.contains("vChewing/") {
lmMisc.dump() lmMisc.dump()
} }
} else {
IME.prtDebugIntel("lmMisc: File access failure: \(path)")
} }
} }
@ -131,53 +137,70 @@ extension vChewing {
if path.contains("vChewing/") { if path.contains("vChewing/") {
lmSymbols.dump() lmSymbols.dump()
} }
} else {
IME.prtDebugIntel("lmSymbols: File access failure: \(path)")
} }
} }
public func loadUserPhrases(path: String, filterPath: String) { public func loadUserPhrases(path: String, filterPath: String) {
if FileManager.default.isReadableFile(atPath: path) { if FileManager.default.isReadableFile(atPath: path) {
lmUserPhrases.close()
lmUserPhrases.open(path) lmUserPhrases.open(path)
IME.prtDebugIntel("lmUserPhrases: \(lmUserPhrases.count) entries of data loaded from: \(path)") IME.prtDebugIntel("lmUserPhrases: \(lmUserPhrases.count) entries of data loaded from: \(path)")
if path.contains("vChewing/") { if path.contains("vChewing/") {
lmUserPhrases.dump() lmUserPhrases.dump()
} }
} else {
IME.prtDebugIntel("lmUserPhrases: File access failure: \(path)")
} }
if FileManager.default.isReadableFile(atPath: filterPath) { if FileManager.default.isReadableFile(atPath: filterPath) {
lmFiltered.close()
lmFiltered.open(filterPath) lmFiltered.open(filterPath)
IME.prtDebugIntel("lmFiltered: \(lmFiltered.count) entries of data loaded from: \(path)") IME.prtDebugIntel("lmFiltered: \(lmFiltered.count) entries of data loaded from: \(path)")
if path.contains("vChewing/") { if path.contains("vChewing/") {
lmFiltered.dump() lmFiltered.dump()
} }
} else {
IME.prtDebugIntel("lmFiltered: File access failure: \(path)")
} }
} }
public func loadUserSymbolData(path: String) { public func loadUserSymbolData(path: String) {
if FileManager.default.isReadableFile(atPath: path) { if FileManager.default.isReadableFile(atPath: path) {
lmUserSymbols.close()
lmUserSymbols.open(path) lmUserSymbols.open(path)
IME.prtDebugIntel("lmUserSymbol: \(lmUserSymbols.count) entries of data loaded from: \(path)") IME.prtDebugIntel("lmUserSymbol: \(lmUserSymbols.count) entries of data loaded from: \(path)")
if path.contains("vChewing/") { if path.contains("vChewing/") {
lmUserSymbols.dump() lmUserSymbols.dump()
} }
} else {
IME.prtDebugIntel("lmUserSymbol: File access failure: \(path)")
} }
} }
public func loadUserAssociatedPhrases(path: String) { public func loadUserAssociatedPhrases(path: String) {
if FileManager.default.isReadableFile(atPath: path) { if FileManager.default.isReadableFile(atPath: path) {
lmAssociates.close()
lmAssociates.open(path) lmAssociates.open(path)
IME.prtDebugIntel("lmAssociates: \(lmAssociates.count) entries of data loaded from: \(path)") IME.prtDebugIntel("lmAssociates: \(lmAssociates.count) entries of data loaded from: \(path)")
if path.contains("vChewing/") { if path.contains("vChewing/") {
lmAssociates.dump() lmAssociates.dump()
} }
} else {
IME.prtDebugIntel("lmAssociates: File access failure: \(path)")
} }
} }
public func loadPhraseReplacementMap(path: String) { public func loadPhraseReplacementMap(path: String) {
if FileManager.default.isReadableFile(atPath: path) { if FileManager.default.isReadableFile(atPath: path) {
lmReplacements.close()
lmReplacements.open(path) lmReplacements.open(path)
IME.prtDebugIntel("lmReplacements: \(lmReplacements.count) entries of data loaded from: \(path)") IME.prtDebugIntel("lmReplacements: \(lmReplacements.count) entries of data loaded from: \(path)")
if path.contains("vChewing/") { if path.contains("vChewing/") {
lmReplacements.dump() lmReplacements.dump()
} }
} else {
IME.prtDebugIntel("lmReplacements: File access failure: \(path)")
} }
} }

View File

@ -46,7 +46,6 @@ extension vChewing {
@discardableResult public mutating func open(_ path: String) -> Bool { @discardableResult public mutating func open(_ path: String) -> Bool {
if isLoaded() { if isLoaded() {
IME.prtDebugIntel("Not loading this one due to isLoaded result of true: \(path)")
return false return false
} }

View File

@ -151,7 +151,7 @@ class mgrLangModel: NSObject {
public static func loadUserPhrases() { public static func loadUserPhrases() {
gLangModelCHT.loadUserPhrases( gLangModelCHT.loadUserPhrases(
path: userSymbolDataPath(InputMode.imeModeCHT), path: userPhrasesDataPath(InputMode.imeModeCHT),
filterPath: excludedPhrasesDataPath(InputMode.imeModeCHT) filterPath: excludedPhrasesDataPath(InputMode.imeModeCHT)
) )
gLangModelCHS.loadUserPhrases( gLangModelCHS.loadUserPhrases(
@ -166,7 +166,7 @@ class mgrLangModel: NSObject {
gLangModelCHT.loadUserAssociatedPhrases( gLangModelCHT.loadUserAssociatedPhrases(
path: mgrLangModel.userAssociatedPhrasesDataPath(InputMode.imeModeCHT) path: mgrLangModel.userAssociatedPhrasesDataPath(InputMode.imeModeCHT)
) )
gLangModelCHT.loadUserAssociatedPhrases( gLangModelCHS.loadUserAssociatedPhrases(
path: mgrLangModel.userAssociatedPhrasesDataPath(InputMode.imeModeCHS) path: mgrLangModel.userAssociatedPhrasesDataPath(InputMode.imeModeCHS)
) )
} }
@ -175,7 +175,7 @@ class mgrLangModel: NSObject {
gLangModelCHT.loadPhraseReplacementMap( gLangModelCHT.loadPhraseReplacementMap(
path: mgrLangModel.phraseReplacementDataPath(InputMode.imeModeCHT) path: mgrLangModel.phraseReplacementDataPath(InputMode.imeModeCHT)
) )
gLangModelCHT.loadPhraseReplacementMap( gLangModelCHS.loadPhraseReplacementMap(
path: mgrLangModel.phraseReplacementDataPath(InputMode.imeModeCHS) path: mgrLangModel.phraseReplacementDataPath(InputMode.imeModeCHS)
) )
} }