LMConsolidator // Add another option to allow force-consolidate, etc.
This commit is contained in:
parent
75f3c371a3
commit
37a96851ea
|
@ -37,7 +37,7 @@ class LMConsolidator
|
||||||
public:
|
public:
|
||||||
static bool CheckPragma(const char *path);
|
static bool CheckPragma(const char *path);
|
||||||
static bool FixEOF(const char *path);
|
static bool FixEOF(const char *path);
|
||||||
static bool ConsolidateContent(const char *path, bool shouldsort);
|
static bool ConsolidateContent(const char *path, bool shouldsort, bool shouldCheckPragma);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace vChewing
|
} // namespace vChewing
|
||||||
|
|
|
@ -71,8 +71,8 @@ bool LMConsolidator::FixEOF(const char *path)
|
||||||
} // END: EOF FIXER.
|
} // END: EOF FIXER.
|
||||||
|
|
||||||
// CONTENT CONSOLIDATOR. CREDIT: Shiki Suen.
|
// CONTENT CONSOLIDATOR. CREDIT: Shiki Suen.
|
||||||
bool LMConsolidator::ConsolidateContent(const char *path, bool shouldsort) {
|
bool LMConsolidator::ConsolidateContent(const char *path, bool shouldsort, bool shouldCheckPragma) {
|
||||||
if (LMConsolidator::CheckPragma(path) && !shouldsort){
|
if (LMConsolidator::CheckPragma(path) && !shouldsort && shouldCheckPragma){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,12 +59,7 @@ bool AssociatedPhrases::open(const char *path)
|
||||||
}
|
}
|
||||||
|
|
||||||
LMConsolidator::FixEOF(path);
|
LMConsolidator::FixEOF(path);
|
||||||
|
LMConsolidator::ConsolidateContent(path, Preferences.shouldAutoSortAssociatedPhrasesOnLoad, true);
|
||||||
if (Preferences.shouldAutoSortAssociatedPhrasesOnLoad) {
|
|
||||||
LMConsolidator::ConsolidateContent(path, true);
|
|
||||||
} else {
|
|
||||||
LMConsolidator::ConsolidateContent(path, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
fd = ::open(path, O_RDONLY);
|
fd = ::open(path, O_RDONLY);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
|
|
|
@ -54,12 +54,7 @@ bool PhraseReplacementMap::open(const char *path)
|
||||||
}
|
}
|
||||||
|
|
||||||
LMConsolidator::FixEOF(path);
|
LMConsolidator::FixEOF(path);
|
||||||
|
LMConsolidator::ConsolidateContent(path, Preferences.shouldAutoSortPhraseReplacementMapOnLoad, true);
|
||||||
if (Preferences.shouldAutoSortPhraseReplacementMapOnLoad) {
|
|
||||||
LMConsolidator::ConsolidateContent(path, true);
|
|
||||||
} else {
|
|
||||||
LMConsolidator::ConsolidateContent(path, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
fd = ::open(path, O_RDONLY);
|
fd = ::open(path, O_RDONLY);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
|
|
|
@ -60,12 +60,7 @@ bool UserPhrasesLM::open(const char *path)
|
||||||
}
|
}
|
||||||
|
|
||||||
LMConsolidator::FixEOF(path);
|
LMConsolidator::FixEOF(path);
|
||||||
|
LMConsolidator::ConsolidateContent(path, Preferences.shouldAutoSortUserPhrasesAndExclListOnLoad, true);
|
||||||
if (Preferences.shouldAutoSortUserPhrasesAndExclListOnLoad) {
|
|
||||||
LMConsolidator::ConsolidateContent(path, true);
|
|
||||||
} else {
|
|
||||||
LMConsolidator::ConsolidateContent(path, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
fd = ::open(path, O_RDONLY);
|
fd = ::open(path, O_RDONLY);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
|
|
|
@ -252,7 +252,9 @@ static void LTLoadLanguageModelFile(NSString *filenameWithoutExtension, vChewing
|
||||||
// }
|
// }
|
||||||
[currentMarkedPhrase appendString:userPhrase];
|
[currentMarkedPhrase appendString:userPhrase];
|
||||||
if (areWeDuplicating) {
|
if (areWeDuplicating) {
|
||||||
[currentMarkedPhrase appendString:@"\tFreqOverrideByDuplication"];
|
// Do not use ASCII characters to comment here.
|
||||||
|
// Otherwise, it will be scrambled by HYPY2BPMF module shipped in the vChewing Phrase Editor.
|
||||||
|
[currentMarkedPhrase appendString:@"\t#𝙾𝚟𝚎𝚛𝚛𝚒𝚍𝚎"];
|
||||||
}
|
}
|
||||||
[currentMarkedPhrase appendString:@"\n"];
|
[currentMarkedPhrase appendString:@"\n"];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue