diff --git a/Source/Base.lproj/preferences.xib b/Source/Base.lproj/preferences.xib index 3a88677a..f361f071 100644 --- a/Source/Base.lproj/preferences.xib +++ b/Source/Base.lproj/preferences.xib @@ -1,6 +1,7 @@ + @@ -238,24 +239,37 @@ + + + + diff --git a/Source/Engine/Gramambular/Bigram.h b/Source/Engine/Gramambular/Bigram.h index a02f5293..db4b09d9 100644 --- a/Source/Engine/Gramambular/Bigram.h +++ b/Source/Engine/Gramambular/Bigram.h @@ -13,7 +13,7 @@ #include "KeyValuePair.h" -namespace Formosa { +namespace Taiyan { namespace Gramambular { class Bigram { public: diff --git a/Source/Engine/Gramambular/BlockReadingBuilder.h b/Source/Engine/Gramambular/BlockReadingBuilder.h index 8186bcf7..b4c5bcc4 100644 --- a/Source/Engine/Gramambular/BlockReadingBuilder.h +++ b/Source/Engine/Gramambular/BlockReadingBuilder.h @@ -13,7 +13,7 @@ #include "Grid.h" #include "LanguageModel.h" -namespace Formosa { +namespace Taiyan { namespace Gramambular { using namespace std; diff --git a/Source/Engine/Gramambular/Grid.h b/Source/Engine/Gramambular/Grid.h index 06c754ed..e15095b2 100644 --- a/Source/Engine/Gramambular/Grid.h +++ b/Source/Engine/Gramambular/Grid.h @@ -13,7 +13,7 @@ #include "NodeAnchor.h" #include "Span.h" -namespace Formosa { +namespace Taiyan { namespace Gramambular { class Grid { diff --git a/Source/Engine/Gramambular/KeyValuePair.h b/Source/Engine/Gramambular/KeyValuePair.h index b9e54094..d2bf00d5 100644 --- a/Source/Engine/Gramambular/KeyValuePair.h +++ b/Source/Engine/Gramambular/KeyValuePair.h @@ -12,7 +12,7 @@ #include #include -namespace Formosa { +namespace Taiyan { namespace Gramambular { using namespace std; diff --git a/Source/Engine/Gramambular/LanguageModel.h b/Source/Engine/Gramambular/LanguageModel.h index 8370b435..c3f35336 100644 --- a/Source/Engine/Gramambular/LanguageModel.h +++ b/Source/Engine/Gramambular/LanguageModel.h @@ -13,7 +13,7 @@ #include "Bigram.h" #include "Unigram.h" -namespace Formosa { +namespace Taiyan { namespace Gramambular { using namespace std; diff --git a/Source/Engine/Gramambular/Node.h b/Source/Engine/Gramambular/Node.h index 7d574cbf..1621ec32 100644 --- a/Source/Engine/Gramambular/Node.h +++ b/Source/Engine/Gramambular/Node.h @@ -13,7 +13,7 @@ #include #include "LanguageModel.h" -namespace Formosa { +namespace Taiyan { namespace Gramambular { using namespace std; diff --git a/Source/Engine/Gramambular/NodeAnchor.h b/Source/Engine/Gramambular/NodeAnchor.h index aa855310..b17f2a4b 100644 --- a/Source/Engine/Gramambular/NodeAnchor.h +++ b/Source/Engine/Gramambular/NodeAnchor.h @@ -11,7 +11,7 @@ #include "Node.h" -namespace Formosa { +namespace Taiyan { namespace Gramambular { class NodeAnchor { public: diff --git a/Source/Engine/Gramambular/Span.h b/Source/Engine/Gramambular/Span.h index fdaf8f9f..5c520572 100644 --- a/Source/Engine/Gramambular/Span.h +++ b/Source/Engine/Gramambular/Span.h @@ -14,7 +14,7 @@ #include #include "Node.h" -namespace Formosa { +namespace Taiyan { namespace Gramambular { class Span { public: diff --git a/Source/Engine/Gramambular/Unigram.h b/Source/Engine/Gramambular/Unigram.h index 283083d4..17540680 100644 --- a/Source/Engine/Gramambular/Unigram.h +++ b/Source/Engine/Gramambular/Unigram.h @@ -12,7 +12,7 @@ #include #include "KeyValuePair.h" -namespace Formosa { +namespace Taiyan { namespace Gramambular { class Unigram { public: diff --git a/Source/Engine/Gramambular/Walker.h b/Source/Engine/Gramambular/Walker.h index ea09d61e..9dbbbf64 100644 --- a/Source/Engine/Gramambular/Walker.h +++ b/Source/Engine/Gramambular/Walker.h @@ -12,7 +12,7 @@ #include #include "Grid.h" -namespace Formosa { +namespace Taiyan { namespace Gramambular { using namespace std; diff --git a/Source/Engine/LanguageModel/FastLM.cpp b/Source/Engine/LanguageModel/FastLM.cpp index f6867562..bcfcf194 100644 --- a/Source/Engine/LanguageModel/FastLM.cpp +++ b/Source/Engine/LanguageModel/FastLM.cpp @@ -14,7 +14,7 @@ #include #include -using namespace Formosa::Gramambular; +using namespace Taiyan::Gramambular; FastLM::FastLM() : fd(-1) diff --git a/Source/Engine/LanguageModel/FastLM.h b/Source/Engine/LanguageModel/FastLM.h index d0a6e9c1..aa94a005 100644 --- a/Source/Engine/LanguageModel/FastLM.h +++ b/Source/Engine/LanguageModel/FastLM.h @@ -18,7 +18,7 @@ // format, and we use mmap and zero-out the separators and line feeds // to avoid creating new string objects; the parser is a simple DFA -namespace Formosa { +namespace Taiyan { namespace Gramambular { class FastLM : public LanguageModel { diff --git a/Source/Engine/LanguageModel/UserOverrideModel.h b/Source/Engine/LanguageModel/UserOverrideModel.h index 6268a9de..7e2e2c09 100644 --- a/Source/Engine/LanguageModel/UserOverrideModel.h +++ b/Source/Engine/LanguageModel/UserOverrideModel.h @@ -17,7 +17,7 @@ namespace vChewing { -using namespace Formosa::Gramambular; +using namespace Taiyan::Gramambular; class UserOverrideModel { public: diff --git a/Source/Engine/LanguageModel/UserPhrasesLM.cpp b/Source/Engine/LanguageModel/UserPhrasesLM.cpp index be7264c2..6d7ee6e1 100644 --- a/Source/Engine/LanguageModel/UserPhrasesLM.cpp +++ b/Source/Engine/LanguageModel/UserPhrasesLM.cpp @@ -94,19 +94,19 @@ void UserPhrasesLM::dump() } } -const std::vector UserPhrasesLM::bigramsForKeys(const std::string& preceedingKey, const std::string& key) +const std::vector UserPhrasesLM::bigramsForKeys(const std::string& preceedingKey, const std::string& key) { - return std::vector(); + return std::vector(); } -const std::vector UserPhrasesLM::unigramsForKey(const std::string& key) +const std::vector UserPhrasesLM::unigramsForKey(const std::string& key) { - std::vector v; + std::vector v; auto iter = keyRowMap.find(key); if (iter != keyRowMap.end()) { const std::vector& rows = iter->second; for (const auto& row : rows) { - Formosa::Gramambular::Unigram g; + Taiyan::Gramambular::Unigram g; g.keyValue.key = row.key; g.keyValue.value = row.value; g.score = 0.0; diff --git a/Source/Engine/LanguageModel/UserPhrasesLM.h b/Source/Engine/LanguageModel/UserPhrasesLM.h index e010b720..c5bfcbc2 100644 --- a/Source/Engine/LanguageModel/UserPhrasesLM.h +++ b/Source/Engine/LanguageModel/UserPhrasesLM.h @@ -16,7 +16,7 @@ namespace vChewing { -class UserPhrasesLM : public Formosa::Gramambular::LanguageModel +class UserPhrasesLM : public Taiyan::Gramambular::LanguageModel { public: UserPhrasesLM(); @@ -26,8 +26,8 @@ public: void close(); void dump(); - virtual const std::vector bigramsForKeys(const std::string& preceedingKey, const std::string& key); - virtual const std::vector unigramsForKey(const std::string& key); + virtual const std::vector bigramsForKeys(const std::string& preceedingKey, const std::string& key); + virtual const std::vector unigramsForKey(const std::string& key); virtual bool hasUnigramsForKey(const std::string& key); protected: diff --git a/Source/Engine/LanguageModel/vChewingLM.h b/Source/Engine/LanguageModel/vChewingLM.h index bd44efde..95bf0d09 100644 --- a/Source/Engine/LanguageModel/vChewingLM.h +++ b/Source/Engine/LanguageModel/vChewingLM.h @@ -16,7 +16,7 @@ namespace vChewing { -using namespace Formosa::Gramambular; +using namespace Taiyan::Gramambular; class vChewingLM : public LanguageModel { public: diff --git a/Source/Engine/Mandarin/Mandarin.cpp b/Source/Engine/Mandarin/Mandarin.cpp index 58c4b35d..17ed259f 100644 --- a/Source/Engine/Mandarin/Mandarin.cpp +++ b/Source/Engine/Mandarin/Mandarin.cpp @@ -13,7 +13,7 @@ #include "OVUTF8Helper.h" #include "OVWildcard.h" -namespace Formosa { +namespace Taiyan { namespace Mandarin { using namespace OpenVanilla; @@ -991,4 +991,4 @@ const BopomofoKeyboardLayout* BopomofoKeyboardLayout::HanyuPinyinLayout() } // namespace Mandarin -} // namespace Formosa +} // namespace Taiyan diff --git a/Source/Engine/Mandarin/Mandarin.h b/Source/Engine/Mandarin/Mandarin.h index 48e4e9d6..b60a4bb3 100644 --- a/Source/Engine/Mandarin/Mandarin.h +++ b/Source/Engine/Mandarin/Mandarin.h @@ -14,7 +14,7 @@ #include #include -namespace Formosa { +namespace Taiyan { namespace Mandarin { using namespace std; diff --git a/Source/Engine/vChewing/clsOOBEDefaults.swift b/Source/Engine/vChewing/clsOOBEDefaults.swift index 95ddfff7..324cf355 100644 --- a/Source/Engine/vChewing/clsOOBEDefaults.swift +++ b/Source/Engine/vChewing/clsOOBEDefaults.swift @@ -12,6 +12,7 @@ private let kShouldNotFartInLieuOfBeep = "ShouldNotFartInLieuOfBeep" private let kCheckUpdateAutomatically = "CheckUpdateAutomatically" private let kCandidateListTextSize = "CandidateListTextSize" private let kChooseCandidateUsingSpaceKey = "ChooseCandidateUsingSpaceKey" +private let kUseWinNT351BPMF = "UseWinNT351BPMF" private let kSelectPhraseAfterCursorAsCandidate = "SelectPhraseAfterCursorAsCandidate" private let kUseHorizontalCandidateList = "UseHorizontalCandidateList" private let kChineseConversionEnabledKey = "ChineseConversionEnabled" @@ -38,6 +39,11 @@ private let kPhraseReplacementEnabledKey = "PhraseReplacementEnabled" UserDefaults.standard.set(Preferences.chooseCandidateUsingSpace, forKey: kChooseCandidateUsingSpaceKey) } + // 預設禁用 WinNT351 風格的注音選字模式(就是每個字都要選的那種),所以設成 false + if UserDefaults.standard.object(forKey: kUseWinNT351BPMF) == nil { + UserDefaults.standard.set(Preferences.useWinNT351BPMF, forKey: kUseWinNT351BPMF) + } + // 預設漢音風格選字,所以要設成 0 if UserDefaults.standard.object(forKey: kSelectPhraseAfterCursorAsCandidate) == nil { UserDefaults.standard.set(Preferences.selectPhraseAfterCursorAsCandidate, forKey: kSelectPhraseAfterCursorAsCandidate) diff --git a/Source/InputMethodController.h b/Source/InputMethodController.h index f8148cd7..ac0269d6 100644 --- a/Source/InputMethodController.h +++ b/Source/InputMethodController.h @@ -18,7 +18,7 @@ { @private // the reading buffer that takes user input - Formosa::Mandarin::BopomofoReadingBuffer* _bpmfReadingBuffer; + Taiyan::Mandarin::BopomofoReadingBuffer* _bpmfReadingBuffer; // language model vChewing::vChewingLM *_languageModel; @@ -27,10 +27,10 @@ vChewing::UserOverrideModel *_userOverrideModel; // the grid (lattice) builder for the unigrams (and bigrams) - Formosa::Gramambular::BlockReadingBuilder* _builder; + Taiyan::Gramambular::BlockReadingBuilder* _builder; // latest walked path (trellis) using the Viterbi algorithm - std::vector _walkedNodes; + std::vector _walkedNodes; // user override model vChewing::UserOverrideModel *_uom; diff --git a/Source/InputMethodController.mm b/Source/InputMethodController.mm index 60c16cac..44335a86 100644 --- a/Source/InputMethodController.mm +++ b/Source/InputMethodController.mm @@ -7,6 +7,7 @@ */ #import "InputMethodController.h" +#include #import #import #import @@ -17,8 +18,8 @@ // C++ namespace usages using namespace std; -using namespace Formosa::Mandarin; -using namespace Formosa::Gramambular; +using namespace Taiyan::Mandarin; +using namespace Taiyan::Gramambular; using namespace vChewing; using namespace OpenVanilla; @@ -109,7 +110,7 @@ static double FindHighestScore(const vector& nodes, double epsilon) _bpmfReadingBuffer = new BopomofoReadingBuffer(BopomofoKeyboardLayout::StandardLayout()); // create the lattice builder - _languageModel = [LanguageModelManager languageModelBopomofo]; + _languageModel = [LanguageModelManager languageModelCoreCHT]; _languageModel->setPhraseReplacementEnabled(Preferences.phraseReplacementEnabled); _userOverrideModel = [LanguageModelManager userOverrideModel]; @@ -151,17 +152,12 @@ static double FindHighestScore(const vector& nodes, double epsilon) [menu addItem:[NSMenuItem separatorItem]]; // ------------------------------ - if (_inputMode == kBopomofoModeIdentifierCHS) { - NSMenuItem *editExcludedPhrasesItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Edit Excluded Phrases", @"") action:@selector(openExcludedPhrasesSimpBopomofo:) keyEquivalent:@""]; - [menu addItem:editExcludedPhrasesItem]; - } - else { - [menu addItemWithTitle:NSLocalizedString(@"Edit User Phrases", @"") action:@selector(openUserPhrases:) keyEquivalent:@""]; - [menu addItemWithTitle:NSLocalizedString(@"Edit Excluded Phrases", @"") action:@selector(openExcludedPhrasesvChewing:) keyEquivalent:@""]; - if (optionKeyPressed) { - [menu addItemWithTitle:NSLocalizedString(@"Edit Phrase Replacement Table", @"") action:@selector(openPhraseReplacementvChewing:) keyEquivalent:@""]; - } + [menu addItemWithTitle:NSLocalizedString(@"Edit User Phrases", @"") action:@selector(openUserPhrases:) keyEquivalent:@""]; + if (optionKeyPressed) { + [menu addItemWithTitle:NSLocalizedString(@"Edit Excluded Phrases", @"") action:@selector(openExcludedPhrases:) keyEquivalent:@""]; + [menu addItemWithTitle:NSLocalizedString(@"Edit Phrase Replacement Table", @"") action:@selector(openPhraseReplacement:) keyEquivalent:@""]; } + [menu addItemWithTitle:NSLocalizedString(@"Reload User Phrases", @"") action:@selector(reloadUserPhrases:) keyEquivalent:@""]; [menu addItem:[NSMenuItem separatorItem]]; // ------------------------------ @@ -248,14 +244,15 @@ static double FindHighestScore(const vector& nodes, double epsilon) if ([value isKindOfClass:[NSString class]] && [value isEqual:kBopomofoModeIdentifierCHS]) { newInputMode = kBopomofoModeIdentifierCHS; - newLanguageModel = [LanguageModelManager languageModelSimpBopomofo]; - } - else { + newLanguageModel = [LanguageModelManager languageModelCoreCHS]; + } else { newInputMode = kBopomofoModeIdentifierCHT; - newLanguageModel = [LanguageModelManager languageModelBopomofo]; - newLanguageModel->setPhraseReplacementEnabled(Preferences.phraseReplacementEnabled); + newLanguageModel = [LanguageModelManager languageModelCoreCHT]; } + // 自 Preferences 模組讀入自訂語彙置換功能開關狀態。 + newLanguageModel->setPhraseReplacementEnabled(Preferences.phraseReplacementEnabled); + // Only apply the changes if the value is changed if (![_inputMode isEqualToString:newInputMode]) { [[NSUserDefaults standardUserDefaults] synchronize]; @@ -650,8 +647,7 @@ NS_INLINE size_t max(size_t a, size_t b) { return a > b ? a : b; } [self popOverflowComposingTextAndWalk:client]; // get user override model suggestion - string overrideValue = (_inputMode == kBopomofoModeIdentifierCHS) ? "" : - _userOverrideModel->suggest(_walkedNodes, _builder->cursorIndex(), [[NSDate date] timeIntervalSince1970]); + string overrideValue = _userOverrideModel->suggest(_walkedNodes, _builder->cursorIndex(), [[NSDate date] timeIntervalSince1970]); if (!overrideValue.empty()) { size_t cursorIndex = [self actualCandidateCursorIndex]; @@ -663,11 +659,14 @@ NS_INLINE size_t max(size_t a, size_t b) { return a > b ? a : b; } // then update the text _bpmfReadingBuffer->clear(); [self updateClientComposingBuffer:client]; - - if (_inputMode == kBopomofoModeIdentifierCHS) { + + // 模擬 WINNT 351 ㄅ半注音,就是每個漢字都自動要選字的那種注音。 + // 嚴格來講不能算純正的ㄅ半注音,畢竟候選字的順序不可能會像當年那樣了。 + // 如果簡體中文用戶不知道ㄅ半注音是什麼的話,拿全拼輸入法來比喻恐怕比較恰當。 + if (Preferences.useWinNT351BPMF) { [self _showCandidateWindowUsingVerticalMode:useVerticalMode client:client]; } - + // and tells the client that the key is consumed return YES; } @@ -965,7 +964,7 @@ NS_INLINE size_t max(size_t a, size_t b) { return a > b ? a : b; } } [self updateClientComposingBuffer:client]; - if (_inputMode == kBopomofoModeIdentifierCHS && _bpmfReadingBuffer->isEmpty()) { + if (Preferences.useWinNT351BPMF && _bpmfReadingBuffer->isEmpty()) { [self collectCandidates]; if ([_candidates count] == 1) { [self commitComposition:client]; @@ -983,14 +982,14 @@ NS_INLINE size_t max(size_t a, size_t b) { return a > b ? a : b; } { BOOL cancelCandidateKey = (charCode == 27) || - ((_inputMode == kBopomofoModeIdentifierCHS) && + (Preferences.useWinNT351BPMF && (charCode == 8 || keyCode == kDeleteKeyCode)); if (cancelCandidateKey) { gCurrentCandidateController.visible = NO; [_candidates removeAllObjects]; - if (_inputMode == kBopomofoModeIdentifierCHS) { + if (Preferences.useWinNT351BPMF) { _builder->clear(); _walkedNodes.clear(); [_composingBuffer setString:@""]; @@ -1147,7 +1146,7 @@ NS_INLINE size_t max(size_t a, size_t b) { return a > b ? a : b; } } } - if (_inputMode == kBopomofoModeIdentifierCHS) { + if (Preferences.useWinNT351BPMF) { string layout = [self _currentLayout]; string customPunctuation = string("_punctuation_") + layout + string(1, (char)charCode); string punctuation = string("_punctuation_") + string(1, (char)charCode); @@ -1316,7 +1315,7 @@ NS_INLINE size_t max(size_t a, size_t b) { return a > b ? a : b; } gCurrentCandidateController.keyLabels = keyLabels; [self collectCandidates]; - if (_inputMode == kBopomofoModeIdentifierCHS && [_candidates count] == 1) { + if (Preferences.useWinNT351BPMF && [_candidates count] == 1) { [self commitComposition:client]; return; } @@ -1493,7 +1492,7 @@ NS_INLINE size_t max(size_t a, size_t b) { return a > b ? a : b; } - (void)togglePhraseReplacementEnabled:(id)sender { BOOL enabled = [Preferences tooglePhraseReplacementEnabled]; - vChewingLM *lm = [LanguageModelManager languageModelBopomofo]; + vChewingLM *lm = [LanguageModelManager languageModelCoreCHT]; lm->setPhraseReplacementEnabled(enabled); } @@ -1532,12 +1531,12 @@ NS_INLINE size_t max(size_t a, size_t b) { return a > b ? a : b; } [self _openUserFile:[LanguageModelManager excludedPhrasesDataPathSimpBopomofo]]; } -- (void)openExcludedPhrasesvChewing:(id)sender +- (void)openExcludedPhrases:(id)sender { [self _openUserFile:[LanguageModelManager excludedPhrasesDataPathBopomofo]]; } -- (void)openPhraseReplacementvChewing:(id)sender +- (void)openPhraseReplacement:(id)sender { [self _openUserFile:[LanguageModelManager phraseReplacementDataPathBopomofo]]; } @@ -1580,7 +1579,7 @@ NS_INLINE size_t max(size_t a, size_t b) { return a > b ? a : b; } size_t cursorIndex = [self actualCandidateCursorIndex]; _builder->grid().fixNodeSelectedCandidate(cursorIndex, selectedValue); - if (_inputMode != kBopomofoModeIdentifierCHS) { + if (!Preferences.useWinNT351BPMF) { _userOverrideModel->observe(_walkedNodes, cursorIndex, selectedValue, [[NSDate date] timeIntervalSince1970]); } @@ -1589,7 +1588,7 @@ NS_INLINE size_t max(size_t a, size_t b) { return a > b ? a : b; } [self walk]; [self updateClientComposingBuffer:_currentCandidateClient]; - if (_inputMode == kBopomofoModeIdentifierCHS) { + if (Preferences.useWinNT351BPMF) { [self commitComposition:_currentCandidateClient]; return; } diff --git a/Source/LanguageModelManager.h b/Source/LanguageModelManager.h index 9fd939a2..aa9a6f04 100644 --- a/Source/LanguageModelManager.h +++ b/Source/LanguageModelManager.h @@ -26,8 +26,8 @@ NS_ASSUME_NONNULL_BEGIN @property (class, readonly, nonatomic) NSString *excludedPhrasesDataPathBopomofo; @property (class, readonly, nonatomic) NSString *excludedPhrasesDataPathSimpBopomofo; @property (class, readonly, nonatomic) NSString *phraseReplacementDataPathBopomofo; -@property (class, readonly, nonatomic) vChewing::vChewingLM *languageModelBopomofo; -@property (class, readonly, nonatomic) vChewing::vChewingLM *languageModelSimpBopomofo; +@property (class, readonly, nonatomic) vChewing::vChewingLM *languageModelCoreCHT; +@property (class, readonly, nonatomic) vChewing::vChewingLM *languageModelCoreCHS; @property (class, readonly, nonatomic) vChewing::UserOverrideModel *userOverrideModel; @end diff --git a/Source/LanguageModelManager.mm b/Source/LanguageModelManager.mm index 1c6d93a4..da968817 100644 --- a/Source/LanguageModelManager.mm +++ b/Source/LanguageModelManager.mm @@ -14,15 +14,15 @@ #import "OVUTF8Helper.h" using namespace std; -using namespace Formosa::Gramambular; +using namespace Taiyan::Gramambular; using namespace vChewing; using namespace OpenVanilla; static const int kUserOverrideModelCapacity = 500; static const double kObservedOverrideHalflife = 5400.0; // 1.5 hr. -vChewingLM gLanguageModelBopomofo; -vChewingLM gLanguageModelSimpBopomofo; +vChewingLM glanguageModelCoreCHT; +vChewingLM glanguageModelCoreCHS; UserOverrideModel gUserOverrideModel(kUserOverrideModelCapacity, kObservedOverrideHalflife); @implementation LanguageModelManager @@ -36,19 +36,19 @@ static void LTLoadLanguageModelFile(NSString *filenameWithoutExtension, vChewing + (void)loadDataModels { - LTLoadLanguageModelFile(@"data-cht", gLanguageModelBopomofo); - LTLoadLanguageModelFile(@"data-chs", gLanguageModelSimpBopomofo); + LTLoadLanguageModelFile(@"data-cht", glanguageModelCoreCHT); + LTLoadLanguageModelFile(@"data-chs", glanguageModelCoreCHS); } + (void)loadUserPhrases { - gLanguageModelBopomofo.loadUserPhrases([[self userPhrasesDataPathBopomofo] UTF8String], [[self excludedPhrasesDataPathBopomofo] UTF8String]); - gLanguageModelSimpBopomofo.loadUserPhrases(NULL, [[self excludedPhrasesDataPathSimpBopomofo] UTF8String]); + glanguageModelCoreCHT.loadUserPhrases([[self userPhrasesDataPathBopomofo] UTF8String], [[self excludedPhrasesDataPathBopomofo] UTF8String]); + glanguageModelCoreCHS.loadUserPhrases(NULL, [[self excludedPhrasesDataPathSimpBopomofo] UTF8String]); } + (void)loadUserPhraseReplacement { - gLanguageModelBopomofo.loadPhraseReplacementMap([[self phraseReplacementDataPathBopomofo] UTF8String]); + glanguageModelCoreCHT.loadPhraseReplacementMap([[self phraseReplacementDataPathBopomofo] UTF8String]); } + (BOOL)checkIfUserDataFolderExists @@ -183,14 +183,14 @@ static void LTLoadLanguageModelFile(NSString *filenameWithoutExtension, vChewing return [[self dataFolderPath] stringByAppendingPathComponent:@"phrases-replacement.txt"]; } - + (vChewingLM *)languageModelBopomofo + + (vChewingLM *)languageModelCoreCHT { - return &gLanguageModelBopomofo; + return &glanguageModelCoreCHT; } -+ (vChewingLM *)languageModelSimpBopomofo ++ (vChewingLM *)languageModelCoreCHS { - return &gLanguageModelSimpBopomofo; + return &glanguageModelCoreCHS; } + (vChewing::UserOverrideModel *)userOverrideModel diff --git a/Source/PreferencesModule.swift b/Source/PreferencesModule.swift index 718ea55a..406df11b 100644 --- a/Source/PreferencesModule.swift +++ b/Source/PreferencesModule.swift @@ -20,6 +20,7 @@ private let kChooseCandidateUsingSpaceKey = "ChooseCandidateUsingSpaceKey" private let kChineseConversionEnabledKey = "ChineseConversionEnabled" private let kHalfWidthPunctuationEnabledKey = "HalfWidthPunctuationEnable" private let kEscToCleanInputBufferKey = "EscToCleanInputBuffer" +private let kUseWinNT351BPMF = "UseWinNT351BPMF" private let kShouldNotFartInLieuOfBeep = "ShouldNotFartInLieuOfBeep" private let kCandidateTextFontName = "CandidateTextFontName" @@ -193,6 +194,9 @@ struct ComposingBufferSize { @UserDefault(key: kChooseCandidateUsingSpaceKey, defaultValue: true) @objc static var chooseCandidateUsingSpace: Bool + @UserDefault(key: kUseWinNT351BPMF, defaultValue: false) + @objc static var useWinNT351BPMF: Bool + @UserDefault(key: kShouldNotFartInLieuOfBeep, defaultValue: true) @objc static var shouldNotFartInLieuOfBeep: Bool diff --git a/Source/PreferencesWindowController.swift b/Source/PreferencesWindowController.swift index 02dff650..b8a76058 100644 --- a/Source/PreferencesWindowController.swift +++ b/Source/PreferencesWindowController.swift @@ -128,7 +128,7 @@ extension RangeReplaceableCollection where Element: Hashable { @IBAction func clickedWhetherIMEShouldNotFartToggleAction(_ sender: Any) { clsSFX.beep() } - + @IBAction func changeSelectionKeyAction(_ sender: Any) { guard let keys = (sender as AnyObject).stringValue?.trimmingCharacters(in: .whitespacesAndNewlines).charDeDuplicate else { return diff --git a/Source/en.lproj/preferences.strings b/Source/en.lproj/preferences.strings index 8fa9fb3b..47550c91 100644 --- a/Source/en.lproj/preferences.strings +++ b/Source/en.lproj/preferences.strings @@ -98,11 +98,14 @@ /* Class = "NSTextFieldCell"; title = "Choose which keys you prefer for selecting candidates."; ObjectID = "2pS-nv-te4"; */ "2pS-nv-te4.title" = "Choose which keys you prefer for selecting candidates."; +/* Class = "NSButtonCell"; title = "Stop farting (when typed phonetic combination is invalid, etc.)"; ObjectID = "62u-jY-BRh"; */ +"62u-jY-BRh.title" = "Stop farting (when typed phonetic combination is invalid, etc.)"; + /* Class = "NSTextFieldCell"; title = "UI language setting:"; ObjectID = "9DS-Rc-TXq"; */ "9DS-Rc-TXq.title" = "UI language setting:"; -/* Class = "NSButtonCell"; title = "Stop farting (when typed phonetic combination is invalid, etc.)"; ObjectID = "ArK-Vk-OoT"; */ -"ArK-Vk-OoT.title" = "Stop farting (when typed phonetic combination is invalid, etc.)"; +/* Class = "NSButtonCell"; title = "Emulating Windows NT 3.51 legacy phonetic typing experience"; ObjectID = "ArK-Vk-OoT"; */ +"ArK-Vk-OoT.title" = "Emulating Windows NT 3.51 legacy phonetic typing experience"; /* Class = "NSButtonCell"; title = "Auto-convert traditional Chinese glyphs to KangXi characters"; ObjectID = "BSK-bH-Gct"; */ "BSK-bH-Gct.title" = "Auto-convert traditional Chinese glyphs to KangXi characters"; diff --git a/Source/zh-Hans.lproj/preferences.strings b/Source/zh-Hans.lproj/preferences.strings index 2f650fce..fc997ad8 100644 --- a/Source/zh-Hans.lproj/preferences.strings +++ b/Source/zh-Hans.lproj/preferences.strings @@ -98,11 +98,14 @@ /* Class = "NSTextFieldCell"; title = "Choose which keys you prefer for selecting candidates."; ObjectID = "2pS-nv-te4"; */ "2pS-nv-te4.title" = "选择您所偏好的用来选字的按键组合。"; +/* Class = "NSButtonCell"; title = "Stop farting (when typed phonetic combination is invalid, etc.)"; ObjectID = "62u-jY-BRh"; */ +"62u-jY-BRh.title" = "不要放屁 // 例:当输入的音韵有误时,等"; + /* Class = "NSTextFieldCell"; title = "UI language setting:"; ObjectID = "9DS-Rc-TXq"; */ "9DS-Rc-TXq.title" = "介面语言设定:"; -/* Class = "NSButtonCell"; title = "Stop farting (when typed phonetic combination is invalid, etc.)"; ObjectID = "ArK-Vk-OoT"; */ -"ArK-Vk-OoT.title" = "不要放屁 // 例:当输入的音韵有误时,等。"; +/* Class = "NSButtonCell"; title = "Emulating Windows NT 3.51 legacy phonetic typing experience"; ObjectID = "ArK-Vk-OoT"; */ +"ArK-Vk-OoT.title" = "模拟 Windows NT 3.51 注音逐字选字输入风格"; /* Class = "NSButtonCell"; title = "Auto-convert traditional Chinese glyphs to KangXi characters"; ObjectID = "BSK-bH-Gct"; */ "BSK-bH-Gct.title" = "自动将繁体中文字转换为康熙字"; diff --git a/Source/zh-Hant.lproj/preferences.strings b/Source/zh-Hant.lproj/preferences.strings index 1b40d2af..a4e2bc65 100644 --- a/Source/zh-Hant.lproj/preferences.strings +++ b/Source/zh-Hant.lproj/preferences.strings @@ -98,11 +98,14 @@ /* Class = "NSTextFieldCell"; title = "Choose which keys you prefer for selecting candidates."; ObjectID = "2pS-nv-te4"; */ "2pS-nv-te4.title" = "選擇您所偏好的用來選字的按鍵組合。"; +/* Class = "NSButtonCell"; title = "Stop farting (when typed phonetic combination is invalid, etc.)"; ObjectID = "62u-jY-BRh"; */ +"62u-jY-BRh.title" = "不要放屁 // 例:當輸入的音韻有誤時,等"; + /* Class = "NSTextFieldCell"; title = "UI language setting:"; ObjectID = "9DS-Rc-TXq"; */ "9DS-Rc-TXq.title" = "介面語言設定:"; -/* Class = "NSButtonCell"; title = "Stop farting (when typed phonetic combination is invalid, etc.)"; ObjectID = "ArK-Vk-OoT"; */ -"ArK-Vk-OoT.title" = "不要放屁 // 例:當輸入的音韻有誤時,等。"; +/* Class = "NSButtonCell"; title = "Emulating Windows NT 3.51 legacy phonetic typing experience"; ObjectID = "ArK-Vk-OoT"; */ +"ArK-Vk-OoT.title" = "模擬 Windows NT 3.51 注音逐字選字輸入風格"; /* Class = "NSButtonCell"; title = "Auto-convert traditional Chinese glyphs to KangXi characters"; ObjectID = "BSK-bH-Gct"; */ "BSK-bH-Gct.title" = "自動將繁體中文字轉換為康熙字"; diff --git a/vChewing.xcodeproj/project.pbxproj b/vChewing.xcodeproj/project.pbxproj index 9765791a..76db6dbd 100644 --- a/vChewing.xcodeproj/project.pbxproj +++ b/vChewing.xcodeproj/project.pbxproj @@ -87,10 +87,10 @@ /* Begin PBXFileReference section */ 5B000FC1278495AD004F02AC /* SimpBopomofo.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = SimpBopomofo.tiff; sourceTree = ""; }; 5B000FC2278495AD004F02AC /* SimpBopomofo@2x.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = "SimpBopomofo@2x.tiff"; sourceTree = ""; }; - 5B054058278787710083EF4A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = Source/en.lproj/preferences.strings; sourceTree = ""; }; 5B19584E27888F5D00FAEB14 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/MainMenu.strings"; sourceTree = ""; }; 5B19584F27888F5F00FAEB14 /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/MainMenu.strings"; sourceTree = ""; }; 5B19585127888F6B00FAEB14 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/MainMenu.strings; sourceTree = ""; }; + 5B4213762796CD0A0089FCF5 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = Source/en.lproj/preferences.strings; sourceTree = ""; }; 5B42B63E27876FDC00BB9B9F /* UserOverrideModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserOverrideModel.cpp; sourceTree = ""; }; 5B42B63F27876FDC00BB9B9F /* UserOverrideModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserOverrideModel.h; sourceTree = ""; }; 5B42B64127877D6500BB9B9F /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "Source/zh-Hans.lproj/preferences.strings"; sourceTree = ""; }; @@ -207,22 +207,6 @@ 6A225A212367A1D700F685C6 /* ArchiveUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArchiveUtil.h; sourceTree = ""; }; 6A225A222367A1D700F685C6 /* ArchiveUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ArchiveUtil.m; sourceTree = ""; }; 6A2E40F5253A69DA00D1AE1D /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; - 6A38BBE215FC117A00A8A51F /* BIG5toUTF8.pl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = BIG5toUTF8.pl; sourceTree = ""; }; - 6A38BBE315FC117A00A8A51F /* build4wlist.bash */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = build4wlist.bash; sourceTree = ""; }; - 6A38BBE415FC117A00A8A51F /* buildFreq.bash */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = buildFreq.bash; sourceTree = ""; }; - 6A38BBE515FC117A00A8A51F /* cook.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = cook.py; sourceTree = ""; }; - 6A38BBE615FC117A00A8A51F /* cook.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = cook.rb; sourceTree = ""; }; - 6A38BBE715FC117A00A8A51F /* count.bash */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = count.bash; sourceTree = ""; }; - 6A38BBE815FC117A00A8A51F /* count.occurrence.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = count.occurrence.c; sourceTree = ""; }; - 6A38BBE915FC117A00A8A51F /* count.occurrence.pl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = count.occurrence.pl; sourceTree = ""; }; - 6A38BBEA15FC117A00A8A51F /* count.occurrence.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = count.occurrence.py; sourceTree = ""; }; - 6A38BBEB15FC117A00A8A51F /* countphrase.bash */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = countphrase.bash; sourceTree = ""; }; - 6A38BBEC15FC117A00A8A51F /* filter.bash */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = filter.bash; sourceTree = ""; }; - 6A38BBED15FC117A00A8A51F /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; - 6A38BBEE15FC117A00A8A51F /* randomShuffle.bash */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = randomShuffle.bash; sourceTree = ""; }; - 6A38BBEF15FC117A00A8A51F /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = ""; }; - 6A38BBF015FC117A00A8A51F /* typocorrection.bash */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = typocorrection.bash; sourceTree = ""; }; - 6A38BBF115FC117A00A8A51F /* utf8length.pl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = utf8length.pl; sourceTree = ""; }; 6A38BBF615FC117A00A8A51F /* data-cht.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "data-cht.txt"; sourceTree = ""; }; 6A38BBFA15FC117A00A8A51F /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; 6A38BC2715FC158A00A8A51F /* InputMethodKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = InputMethodKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/InputMethodKit.framework; sourceTree = DEVELOPER_DIR; }; @@ -513,7 +497,6 @@ 6A38BBDD15FC115800A8A51F /* Data */ = { isa = PBXGroup; children = ( - 6A38BBE115FC117A00A8A51F /* bin */, 6A38BBF615FC117A00A8A51F /* data-cht.txt */, 5BC3FB82278492DE0022E99A /* data-chs.txt */, 6A38BBFA15FC117A00A8A51F /* Makefile */, @@ -521,29 +504,6 @@ path = Data; sourceTree = ""; }; - 6A38BBE115FC117A00A8A51F /* bin */ = { - isa = PBXGroup; - children = ( - 6A38BBE215FC117A00A8A51F /* BIG5toUTF8.pl */, - 6A38BBE315FC117A00A8A51F /* build4wlist.bash */, - 6A38BBE415FC117A00A8A51F /* buildFreq.bash */, - 6A38BBE515FC117A00A8A51F /* cook.py */, - 6A38BBE615FC117A00A8A51F /* cook.rb */, - 6A38BBE715FC117A00A8A51F /* count.bash */, - 6A38BBE815FC117A00A8A51F /* count.occurrence.c */, - 6A38BBE915FC117A00A8A51F /* count.occurrence.pl */, - 6A38BBEA15FC117A00A8A51F /* count.occurrence.py */, - 6A38BBEB15FC117A00A8A51F /* countphrase.bash */, - 6A38BBEC15FC117A00A8A51F /* filter.bash */, - 6A38BBED15FC117A00A8A51F /* Makefile */, - 6A38BBEE15FC117A00A8A51F /* randomShuffle.bash */, - 6A38BBEF15FC117A00A8A51F /* README */, - 6A38BBF015FC117A00A8A51F /* typocorrection.bash */, - 6A38BBF115FC117A00A8A51F /* utf8length.pl */, - ); - path = bin; - sourceTree = ""; - }; 6ACA41E715FC1D9000935EF6 /* Installer */ = { isa = PBXGroup; children = ( @@ -834,7 +794,7 @@ 6A15B32721A51F2300B92CD3 /* Base */, 5B42B64127877D6500BB9B9F /* zh-Hans */, 5B42B64227877D7700BB9B9F /* zh-Hant */, - 5B054058278787710083EF4A /* en */, + 5B4213762796CD0A0089FCF5 /* en */, ); name = preferences.xib; path = ..;