LMConsolidator // Removing Sorting Feature.
- This feature is now considered troublesome, considering that there is no way to control the sorting method in Cpp: Some people prefer sorting things alphabetically, and some prefer counting strokes, etc.
This commit is contained in:
parent
24fcf0b572
commit
128aa74b99
|
@ -37,7 +37,7 @@ class LMConsolidator
|
|||
public:
|
||||
static bool CheckPragma(const char *path);
|
||||
static bool FixEOF(const char *path);
|
||||
static bool ConsolidateContent(const char *path, bool shouldsort, bool shouldCheckPragma);
|
||||
static bool ConsolidateContent(const char *path, bool shouldCheckPragma);
|
||||
};
|
||||
|
||||
} // namespace vChewing
|
||||
|
|
|
@ -71,8 +71,8 @@ bool LMConsolidator::FixEOF(const char *path)
|
|||
} // END: EOF FIXER.
|
||||
|
||||
// CONTENT CONSOLIDATOR. CREDIT: Shiki Suen.
|
||||
bool LMConsolidator::ConsolidateContent(const char *path, bool shouldsort, bool shouldCheckPragma) {
|
||||
if (LMConsolidator::CheckPragma(path) && !shouldsort && shouldCheckPragma){
|
||||
bool LMConsolidator::ConsolidateContent(const char *path, bool shouldCheckPragma) {
|
||||
if (LMConsolidator::CheckPragma(path) && shouldCheckPragma){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -97,8 +97,7 @@ bool LMConsolidator::ConsolidateContent(const char *path, bool shouldsort, bool
|
|||
vecEntry[i] = regex_replace(vecEntry[i], sedTrailingSpace, "").c_str(); // 去掉行尾空格。
|
||||
}
|
||||
}
|
||||
// 在第二遍 for 運算之前,針對 vecEntry 排序+去除重複條目。
|
||||
if (shouldsort) {sort(vecEntry.begin(), vecEntry.end());} // 要不要排序,得做成開關。
|
||||
// 在第二遍 for 運算之前,針對 vecEntry 去除重複條目。
|
||||
vecEntry.erase(unique(vecEntry.begin(), vecEntry.end()), vecEntry.end()); // 去重複。
|
||||
// 統整完畢。開始將統整過的內容寫入檔案。
|
||||
ofstream zfdContentConsolidatorOutput(path); // 這裡是要從頭開始重寫檔案內容,所以不需要「 ios_base::app 」。
|
||||
|
|
|
@ -28,9 +28,6 @@ private let kFunctionKeyKeyboardLayoutOverrideIncludeShift = "FunctionKeyKeyboar
|
|||
private let kCandidateListTextSize = "CandidateListTextSize"
|
||||
private let kAppleLanguagesPreferences = "AppleLanguages"
|
||||
private let kShouldAutoReloadUserDataFiles = "ShouldAutoReloadUserDataFiles"
|
||||
private let kShouldAutoSortUserPhrasesAndExclListOnLoad = "ShouldAutoSortUserPhrasesAndExclListOnLoad"
|
||||
private let kShouldAutoSortPhraseReplacementMapOnLoad = "ShouldAutoSortPhraseReplacementMapOnLoad"
|
||||
private let kShouldAutoSortAssociatedPhrasesOnLoad = "ShouldAutoSortAssociatedPhrasesOnLoad"
|
||||
private let kSelectPhraseAfterCursorAsCandidatePreference = "SelectPhraseAfterCursorAsCandidate"
|
||||
private let kUseHorizontalCandidateListPreference = "UseHorizontalCandidateList"
|
||||
private let kComposingBufferSizePreference = "ComposingBufferSize"
|
||||
|
@ -222,9 +219,6 @@ struct ComposingBufferSize {
|
|||
kCandidateListTextSize,
|
||||
kAppleLanguagesPreferences,
|
||||
kShouldAutoReloadUserDataFiles,
|
||||
kShouldAutoSortUserPhrasesAndExclListOnLoad,
|
||||
kShouldAutoSortPhraseReplacementMapOnLoad,
|
||||
kShouldAutoSortAssociatedPhrasesOnLoad,
|
||||
kSelectPhraseAfterCursorAsCandidatePreference,
|
||||
kUseHorizontalCandidateListPreference,
|
||||
kComposingBufferSizePreference,
|
||||
|
@ -270,26 +264,11 @@ struct ComposingBufferSize {
|
|||
UserDefaults.standard.set(Preferences.chooseCandidateUsingSpace, forKey: kChooseCandidateUsingSpace)
|
||||
}
|
||||
|
||||
// 在檔案載入時,預設不啟用使用者自訂語彙表與語彙排除表的內容排序。
|
||||
// 自動檢測使用者自訂語彙數據的變動並載入。
|
||||
if UserDefaults.standard.object(forKey: kShouldAutoReloadUserDataFiles) == nil {
|
||||
UserDefaults.standard.set(Preferences.shouldAutoReloadUserDataFiles, forKey: kShouldAutoReloadUserDataFiles)
|
||||
}
|
||||
|
||||
// 在檔案載入時,預設不啟用語彙置換表的內容排序。
|
||||
if UserDefaults.standard.object(forKey: kShouldAutoSortUserPhrasesAndExclListOnLoad) == nil {
|
||||
UserDefaults.standard.set(Preferences.shouldAutoSortUserPhrasesAndExclListOnLoad, forKey: kShouldAutoSortUserPhrasesAndExclListOnLoad)
|
||||
}
|
||||
|
||||
// 在檔案載入時,預設不啟用自訂聯想詞表的內容排序。
|
||||
if UserDefaults.standard.object(forKey: kShouldAutoSortAssociatedPhrasesOnLoad) == nil {
|
||||
UserDefaults.standard.set(Preferences.shouldAutoSortAssociatedPhrasesOnLoad, forKey: kShouldAutoSortAssociatedPhrasesOnLoad)
|
||||
}
|
||||
|
||||
// 自動檢測使用者自訂語彙數據的變動並載入。
|
||||
if UserDefaults.standard.object(forKey: kShouldAutoSortPhraseReplacementMapOnLoad) == nil {
|
||||
UserDefaults.standard.set(Preferences.shouldAutoSortPhraseReplacementMapOnLoad, forKey: kShouldAutoSortPhraseReplacementMapOnLoad)
|
||||
}
|
||||
|
||||
// 預設禁用逐字選字模式(就是每個字都要選的那種),所以設成 false
|
||||
if UserDefaults.standard.object(forKey: kUseSCPCTypingMode) == nil {
|
||||
UserDefaults.standard.set(Preferences.useSCPCTypingMode, forKey: kUseSCPCTypingMode)
|
||||
|
@ -371,15 +350,6 @@ struct ComposingBufferSize {
|
|||
@UserDefault(key: kShouldAutoReloadUserDataFiles, defaultValue: true)
|
||||
@objc static var shouldAutoReloadUserDataFiles: Bool
|
||||
|
||||
@UserDefault(key: kShouldAutoSortUserPhrasesAndExclListOnLoad, defaultValue: false)
|
||||
@objc static var shouldAutoSortUserPhrasesAndExclListOnLoad: Bool
|
||||
|
||||
@UserDefault(key: kShouldAutoSortPhraseReplacementMapOnLoad, defaultValue: false)
|
||||
@objc static var shouldAutoSortPhraseReplacementMapOnLoad: Bool
|
||||
|
||||
@UserDefault(key: kShouldAutoSortAssociatedPhrasesOnLoad, defaultValue: false)
|
||||
@objc static var shouldAutoSortAssociatedPhrasesOnLoad: Bool
|
||||
|
||||
@UserDefault(key: kSelectPhraseAfterCursorAsCandidatePreference, defaultValue: true)
|
||||
@objc static var selectPhraseAfterCursorAsCandidate: Bool
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ bool AssociatedPhrases::open(const char *path)
|
|||
}
|
||||
|
||||
LMConsolidator::FixEOF(path);
|
||||
LMConsolidator::ConsolidateContent(path, Preferences.shouldAutoSortAssociatedPhrasesOnLoad, true);
|
||||
LMConsolidator::ConsolidateContent(path, true);
|
||||
|
||||
fd = ::open(path, O_RDONLY);
|
||||
if (fd == -1) {
|
||||
|
|
|
@ -54,7 +54,7 @@ bool PhraseReplacementMap::open(const char *path)
|
|||
}
|
||||
|
||||
LMConsolidator::FixEOF(path);
|
||||
LMConsolidator::ConsolidateContent(path, Preferences.shouldAutoSortPhraseReplacementMapOnLoad, true);
|
||||
LMConsolidator::ConsolidateContent(path, true);
|
||||
|
||||
fd = ::open(path, O_RDONLY);
|
||||
if (fd == -1) {
|
||||
|
|
|
@ -60,7 +60,7 @@ bool UserPhrasesLM::open(const char *path)
|
|||
}
|
||||
|
||||
LMConsolidator::FixEOF(path);
|
||||
LMConsolidator::ConsolidateContent(path, Preferences.shouldAutoSortUserPhrasesAndExclListOnLoad, true);
|
||||
LMConsolidator::ConsolidateContent(path, true);
|
||||
|
||||
fd = ::open(path, O_RDONLY);
|
||||
if (fd == -1) {
|
||||
|
|
|
@ -266,7 +266,7 @@ static void LTLoadLanguageModelFile(NSString *filenameWithoutExtension, vChewing
|
|||
[writeFile closeFile];
|
||||
|
||||
// We enforce the format consolidation here, since the pragma header will let the UserPhraseLM bypasses the consolidating process on load.
|
||||
vChewing::LMConsolidator::ConsolidateContent([path UTF8String], Preferences.shouldAutoSortUserPhrasesAndExclListOnLoad, false);
|
||||
vChewing::LMConsolidator::ConsolidateContent([path UTF8String], false);
|
||||
|
||||
// We use FSEventStream to monitor the change of the user phrase folder,
|
||||
// so we don't have to load data here unless FSEventStream is disabled by user.
|
||||
|
|
|
@ -503,36 +503,8 @@
|
|||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<button translatesAutoresizingMaskIntoConstraints="NO" id="1hA-Po-5li">
|
||||
<rect key="frame" x="19" y="94.5" width="401" height="17"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="288" id="0mm-CA-Mxs"/>
|
||||
<constraint firstAttribute="height" constant="16" id="c3e-cU-pEw"/>
|
||||
</constraints>
|
||||
<buttonCell key="cell" type="check" title="Sort entries when reloading user phrases and excluded phrases list" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" state="on" inset="2" id="Li3-Yg-SOC">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="cellTitle"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<binding destination="32" name="value" keyPath="values.ShouldAutoSortUserPhrasesAndExclListOnLoad" id="k4w-CX-EfE"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="nnT-wS-mZo">
|
||||
<rect key="frame" x="19" y="72.5" width="342" height="17"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="16" id="IBn-Xf-uEw"/>
|
||||
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="234" id="srn-3X-kPi"/>
|
||||
</constraints>
|
||||
<buttonCell key="cell" type="check" title="Sort entries when reloading the phrase replacement map" bezelStyle="regularSquare" imagePosition="left" controlSize="small" state="on" inset="2" id="o60-vW-i1B">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="cellTitle"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<binding destination="32" name="value" keyPath="values.ShouldAutoSortPhraseReplacementMapOnLoad" id="Xn2-So-Dp3"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="p7V-IN-OTr">
|
||||
<rect key="frame" x="19" y="51.5" width="336" height="17"/>
|
||||
<rect key="frame" x="19" y="93.5" width="336" height="17"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="16" id="8eX-Tw-Erk"/>
|
||||
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="234" id="yhP-XF-CQj"/>
|
||||
|
@ -548,17 +520,11 @@
|
|||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" relation="lessThanOrEqual" secondItem="dnE-Vw-KrP" secondAttribute="trailing" constant="214" id="3wA-Rn-cTn"/>
|
||||
<constraint firstItem="nnT-wS-mZo" firstAttribute="leading" secondItem="p7V-IN-OTr" secondAttribute="leading" id="4di-W1-ufn"/>
|
||||
<constraint firstItem="1hA-Po-5li" firstAttribute="leading" secondItem="nnT-wS-mZo" secondAttribute="leading" id="Cfb-2F-MRg"/>
|
||||
<constraint firstItem="1hA-Po-5li" firstAttribute="leading" secondItem="dnE-Vw-KrP" secondAttribute="leading" id="Exw-iA-Unz"/>
|
||||
<constraint firstItem="1hA-Po-5li" firstAttribute="top" secondItem="dnE-Vw-KrP" secondAttribute="bottom" constant="6.5" id="HrQ-4q-l78"/>
|
||||
<constraint firstItem="p7V-IN-OTr" firstAttribute="top" secondItem="dnE-Vw-KrP" secondAttribute="bottom" constant="7.5" id="Arf-UU-TPA"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="p7V-IN-OTr" secondAttribute="trailing" constant="20" symbolic="YES" id="MFR-05-QJN"/>
|
||||
<constraint firstItem="p7V-IN-OTr" firstAttribute="leading" secondItem="dnE-Vw-KrP" secondAttribute="leading" id="MO7-eJ-fcH"/>
|
||||
<constraint firstItem="dnE-Vw-KrP" firstAttribute="leading" secondItem="rWB-y8-q94" secondAttribute="leading" constant="20" id="QQJ-7P-HAG"/>
|
||||
<constraint firstAttribute="trailing" relation="lessThanOrEqual" secondItem="nnT-wS-mZo" secondAttribute="trailing" constant="101" id="QsT-xW-prJ"/>
|
||||
<constraint firstItem="dnE-Vw-KrP" firstAttribute="top" secondItem="rWB-y8-q94" secondAttribute="top" constant="15" id="Vzj-xd-Q2W"/>
|
||||
<constraint firstItem="p7V-IN-OTr" firstAttribute="top" secondItem="nnT-wS-mZo" secondAttribute="bottom" constant="5" id="gRe-fD-67h"/>
|
||||
<constraint firstAttribute="trailing" relation="lessThanOrEqual" secondItem="1hA-Po-5li" secondAttribute="trailing" constant="39" id="quD-Rd-uwL"/>
|
||||
<constraint firstItem="nnT-wS-mZo" firstAttribute="top" secondItem="1hA-Po-5li" secondAttribute="bottom" constant="6" symbolic="YES" id="zxn-Pa-o6f"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<constraints>
|
||||
|
|
|
@ -134,9 +134,6 @@
|
|||
/* Class = "NSMenuItem"; title = "Auto-Select"; ObjectID = "GlJ-Ns-9eE"; */
|
||||
"GlJ-Ns-9eE.title" = "Auto-Select";
|
||||
|
||||
/* Class = "NSButtonCell"; title = "Sort entries when reloading user phrases and excluded phrases list"; ObjectID = "Li3-Yg-SOC"; */
|
||||
"Li3-Yg-SOC.title" = "Sort entries when reloading user phrases and excluded phrases list";
|
||||
|
||||
/* Class = "NSTabViewItem"; label = "General"; ObjectID = "QUQ-oY-4Hc"; */
|
||||
"QUQ-oY-4Hc.label" = "General";
|
||||
|
||||
|
@ -188,9 +185,6 @@
|
|||
/* Class = "NSComboBoxCell"; jQC-12-UuK.ibShadowedObjectValues[2] = "Item 3"; ObjectID = "jQC-12-UuK"; */
|
||||
"jQC-12-UuK.ibShadowedObjectValues[2]" = "Item 3";
|
||||
|
||||
/* Class = "NSButtonCell"; title = "Sort entries when reloading the phrase replacement map"; ObjectID = "o60-vW-i1B"; */
|
||||
"o60-vW-i1B.title" = "Sort entries when reloading the phrase replacement map";
|
||||
|
||||
/* Class = "NSMenuItem"; title = "Japanese"; ObjectID = "rVQ-Hx-cGi"; */
|
||||
"rVQ-Hx-cGi.title" = "Japanese";
|
||||
|
||||
|
|
|
@ -134,9 +134,6 @@
|
|||
/* Class = "NSMenuItem"; title = "Auto-Select"; ObjectID = "GlJ-Ns-9eE"; */
|
||||
"GlJ-Ns-9eE.title" = "システム設定に準ずる";
|
||||
|
||||
/* Class = "NSButtonCell"; title = "Sort entries when reloading user phrases and excluded phrases list"; ObjectID = "Li3-Yg-SOC"; */
|
||||
"Li3-Yg-SOC.title" = "ユーザー辞書と条目排除表を読み込むときに、内容の順番を整う";
|
||||
|
||||
/* Class = "NSTabViewItem"; label = "General"; ObjectID = "QUQ-oY-4Hc"; */
|
||||
"QUQ-oY-4Hc.label" = "全般";
|
||||
|
||||
|
@ -188,9 +185,6 @@
|
|||
/* Class = "NSComboBoxCell"; jQC-12-UuK.ibShadowedObjectValues[2] = "Item 3"; ObjectID = "jQC-12-UuK"; */
|
||||
"jQC-12-UuK.ibShadowedObjectValues[2]" = "Item 3";
|
||||
|
||||
/* Class = "NSButtonCell"; title = "Sort entries when reloading the phrase replacement map"; ObjectID = "o60-vW-i1B"; */
|
||||
"o60-vW-i1B.title" = "言葉置換表を読み込むときに、内容の順番を整う";
|
||||
|
||||
/* Class = "NSMenuItem"; title = "Japanese"; ObjectID = "rVQ-Hx-cGi"; */
|
||||
"rVQ-Hx-cGi.title" = "和語";
|
||||
|
||||
|
|
|
@ -134,9 +134,6 @@
|
|||
/* Class = "NSMenuItem"; title = "Auto-Select"; ObjectID = "GlJ-Ns-9eE"; */
|
||||
"GlJ-Ns-9eE.title" = "自动选择";
|
||||
|
||||
/* Class = "NSButtonCell"; title = "Sort entries when reloading user phrases and excluded phrases list"; ObjectID = "Li3-Yg-SOC"; */
|
||||
"Li3-Yg-SOC.title" = "在重新加载自订语汇与滤除语汇时,统整档案内容排序";
|
||||
|
||||
/* Class = "NSTabViewItem"; label = "General"; ObjectID = "QUQ-oY-4Hc"; */
|
||||
"QUQ-oY-4Hc.label" = "一般";
|
||||
|
||||
|
@ -188,9 +185,6 @@
|
|||
/* Class = "NSComboBoxCell"; jQC-12-UuK.ibShadowedObjectValues[2] = "Item 3"; ObjectID = "jQC-12-UuK"; */
|
||||
"jQC-12-UuK.ibShadowedObjectValues[2]" = "Item 3";
|
||||
|
||||
/* Class = "NSButtonCell"; title = "Sort entries when reloading the phrase replacement map"; ObjectID = "o60-vW-i1B"; */
|
||||
"o60-vW-i1B.title" = "在重新加载语汇滤除表时,统整档案内容排序";
|
||||
|
||||
/* Class = "NSMenuItem"; title = "Japanese"; ObjectID = "rVQ-Hx-cGi"; */
|
||||
"rVQ-Hx-cGi.title" = "和语";
|
||||
|
||||
|
|
|
@ -134,9 +134,6 @@
|
|||
/* Class = "NSMenuItem"; title = "Auto-Select"; ObjectID = "GlJ-Ns-9eE"; */
|
||||
"GlJ-Ns-9eE.title" = "自動選擇";
|
||||
|
||||
/* Class = "NSButtonCell"; title = "Sort entries when reloading user phrases and excluded phrases list"; ObjectID = "Li3-Yg-SOC"; */
|
||||
"Li3-Yg-SOC.title" = "在重新載入自訂語彙與濾除語彙時,統整檔案內容排序";
|
||||
|
||||
/* Class = "NSTabViewItem"; label = "General"; ObjectID = "QUQ-oY-4Hc"; */
|
||||
"QUQ-oY-4Hc.label" = "一般";
|
||||
|
||||
|
@ -188,9 +185,6 @@
|
|||
/* Class = "NSComboBoxCell"; jQC-12-UuK.ibShadowedObjectValues[2] = "Item 3"; ObjectID = "jQC-12-UuK"; */
|
||||
"jQC-12-UuK.ibShadowedObjectValues[2]" = "Item 3";
|
||||
|
||||
/* Class = "NSButtonCell"; title = "Sort entries when reloading the phrase replacement map"; ObjectID = "o60-vW-i1B"; */
|
||||
"o60-vW-i1B.title" = "在重新載入語彙濾除表時,統整檔案內容排序";
|
||||
|
||||
/* Class = "NSMenuItem"; title = "Japanese"; ObjectID = "rVQ-Hx-cGi"; */
|
||||
"rVQ-Hx-cGi.title" = "和語";
|
||||
|
||||
|
|
Loading…
Reference in New Issue