diff --git a/Source/Modules/FileHandlers/LMConsolidator.swift b/Source/Modules/FileHandlers/LMConsolidator.swift index 93e79967..b0fae6cd 100644 --- a/Source/Modules/FileHandlers/LMConsolidator.swift +++ b/Source/Modules/FileHandlers/LMConsolidator.swift @@ -33,8 +33,8 @@ extension vChewing { let fileHandle = FileHandle(forReadingAtPath: path)! do { let lineReader = try LineReader(file: fileHandle) - IME.prtDebugIntel("Header Seen ||\(lineReader)") for strLine in lineReader { // 不需要 i=0,因為第一遍迴圈就出結果。 + IME.prtDebugIntel("Header Seen ||\(strLine)") if strLine != kPragmaHeader { IME.prtDebugIntel("Header Mismatch, Starting In-Place Consolidation.") return false @@ -68,7 +68,7 @@ extension vChewing { IME.prtDebugIntel("EOF Fix Failed w/ Error: \(error).") return false } - IME.prtDebugIntel("Either EOF Fix Successful Or No-Need-To-Fix.") + IME.prtDebugIntel("EOF Successfully Ensured (with possible autofixes performed).") return true } IME.prtDebugIntel("EOF Fix Failed: File Missing at \(path).") diff --git a/Source/Modules/LangModelRelated/mgrLangModel.h b/Source/Modules/LangModelRelated/mgrLangModel.h index b7bfbae1..f76fcbec 100644 --- a/Source/Modules/LangModelRelated/mgrLangModel.h +++ b/Source/Modules/LangModelRelated/mgrLangModel.h @@ -39,7 +39,6 @@ NS_ASSUME_NONNULL_BEGIN + (BOOL)checkIfUserPhraseExist:(NSString *)userPhrase inputMode:(InputMode)mode key:(NSString *)key NS_SWIFT_NAME(checkIfUserPhraseExist(userPhrase:mode:key:)); -+ (void)consolidateGivenFile:(NSString *)path shouldCheckPragma:(BOOL)shouldCheckPragma; + (void)setPhraseReplacementEnabled:(BOOL)phraseReplacementEnabled; + (void)setCNSEnabled:(BOOL)cnsEnabled; + (void)setSymbolEnabled:(BOOL)symbolEnabled; diff --git a/Source/Modules/LangModelRelated/mgrLangModel.mm b/Source/Modules/LangModelRelated/mgrLangModel.mm index 065a5afb..7c3fae20 100644 --- a/Source/Modules/LangModelRelated/mgrLangModel.mm +++ b/Source/Modules/LangModelRelated/mgrLangModel.mm @@ -141,12 +141,6 @@ static void LTLoadLanguageModelFile(NSString *filenameWithoutExtension, vChewing return NO; } -// 這個函數無法遷移至 Swift -+ (void)consolidateGivenFile:(NSString *)path shouldCheckPragma:(BOOL)shouldCheckPragma -{ - vChewing::LMConsolidator::ConsolidateContent([path UTF8String], shouldCheckPragma); -} - // 這個函數無法遷移至 Swift + (vChewing::LMInstantiator *)lmCHT { diff --git a/Source/Modules/LangModelRelated/mgrLangModel.swift b/Source/Modules/LangModelRelated/mgrLangModel.swift index 7e4df687..1c916902 100644 --- a/Source/Modules/LangModelRelated/mgrLangModel.swift +++ b/Source/Modules/LangModelRelated/mgrLangModel.swift @@ -233,7 +233,9 @@ import Cocoa // We enforce the format consolidation here, since the pragma header // will let the UserPhraseLM bypasses the consolidating process on load. - consolidate(givenFile: path, shouldCheckPragma: false) + if !vChewing.LMConsolidator.consolidate(path: path, pragma: false) { + return false + } // We use FSEventStream to monitor possible changes of the user phrase folder, hence the // lack of the needs of manually load data here unless FSEventStream is disabled by user.