From b22748bd724027940655bae825800cc7213bbfd1 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Sun, 20 Feb 2022 19:52:43 +0800 Subject: [PATCH] IME // Rebrand vChewingLM to LMInstantiator. --- .../Modules/ControllerModules/KeyHandler.mm | 6 +-- .../{vChewingLM.h => LMInstantiator.h} | 14 +++--- .../{vChewingLM.mm => LMInstantiator.mm} | 46 +++++++++---------- .../Modules/LangModelRelated/mgrLangModel.mm | 10 ++-- .../LangModelRelated/mgrLangModel_Privates.h | 6 +-- vChewing.xcodeproj/project.pbxproj | 12 ++--- 6 files changed, 47 insertions(+), 47 deletions(-) rename Source/Modules/LangModelRelated/{vChewingLM.h => LMInstantiator.h} (95%) rename Source/Modules/LangModelRelated/{vChewingLM.mm => LMInstantiator.mm} (80%) diff --git a/Source/Modules/ControllerModules/KeyHandler.mm b/Source/Modules/ControllerModules/KeyHandler.mm index 5e38edc0..b6ecfbb5 100644 --- a/Source/Modules/ControllerModules/KeyHandler.mm +++ b/Source/Modules/ControllerModules/KeyHandler.mm @@ -19,7 +19,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH #import "Mandarin.h" #import "Gramambular.h" -#import "vChewingLM.h" +#import "LMInstantiator.h" #import "UserOverrideModel.h" #import "mgrLangModel_Privates.h" #import "KeyHandler.h" @@ -71,7 +71,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; Taiyan::Mandarin::BopomofoReadingBuffer *_bpmfReadingBuffer; // language model - vChewing::vChewingLM *_languageModel; + vChewing::LMInstantiator *_languageModel; // user override model vChewing::UserOverrideModel *_userOverrideModel; @@ -96,7 +96,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; - (void)setInputMode:(NSString *)value { NSString *newInputMode; - vChewingLM *newLanguageModel; + LMInstantiator *newLanguageModel; UserOverrideModel *newUserOverrideModel; if ([value isKindOfClass:[NSString class]] && [value isEqual:imeModeCHS]) { diff --git a/Source/Modules/LangModelRelated/vChewingLM.h b/Source/Modules/LangModelRelated/LMInstantiator.h similarity index 95% rename from Source/Modules/LangModelRelated/vChewingLM.h rename to Source/Modules/LangModelRelated/LMInstantiator.h index 6ab58fa2..0ee9096c 100644 --- a/Source/Modules/LangModelRelated/vChewingLM.h +++ b/Source/Modules/LangModelRelated/LMInstantiator.h @@ -17,8 +17,8 @@ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABI TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VCHEWINGLM_H -#define VCHEWINGLM_H +#ifndef LMInstantiator_H +#define LMInstantiator_H #include #include "UserPhrasesLM.h" @@ -32,7 +32,7 @@ namespace vChewing { using namespace Taiyan::Gramambular; -/// vChewingLM is a facade for managing a set of models including +/// LMInstantiator is a facade for managing a set of models including /// the input method language model, user phrases and excluded phrases. /// /// It is the primary model class that the input controller and grammar builder @@ -41,7 +41,7 @@ using namespace Taiyan::Gramambular; /// if there are valid unigrams, and use returned unigrams to produce the final /// results. /// -/// vChewingLM combine and transform the unigrams from the primary language +/// LMInstantiator combine and transform the unigrams from the primary language /// model and user phrases. The process is /// /// 1) Get the original unigrams. @@ -54,10 +54,10 @@ using namespace Taiyan::Gramambular; /// model while launching and to load the user phrases anytime if the custom /// files are modified. It does not keep the reference of the data pathes but /// you have to pass the paths when you ask it to do loading. -class vChewingLM : public LanguageModel { +class LMInstantiator : public LanguageModel { public: - vChewingLM(); - ~vChewingLM(); + LMInstantiator(); + ~LMInstantiator(); /// Asks to load the primary language model at the given path. /// @param languageModelPath The path of the language model. diff --git a/Source/Modules/LangModelRelated/vChewingLM.mm b/Source/Modules/LangModelRelated/LMInstantiator.mm similarity index 80% rename from Source/Modules/LangModelRelated/vChewingLM.mm rename to Source/Modules/LangModelRelated/LMInstantiator.mm index 99f6a2e3..299edb64 100644 --- a/Source/Modules/LangModelRelated/vChewingLM.mm +++ b/Source/Modules/LangModelRelated/LMInstantiator.mm @@ -17,17 +17,17 @@ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABI TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "vChewingLM.h" +#include "LMInstantiator.h" #include #include using namespace vChewing; -vChewingLM::vChewingLM() +LMInstantiator::LMInstantiator() { } -vChewingLM::~vChewingLM() +LMInstantiator::~LMInstantiator() { m_languageModel.close(); m_userPhrases.close(); @@ -37,7 +37,7 @@ vChewingLM::~vChewingLM() m_associatedPhrases.close(); } -void vChewingLM::loadLanguageModel(const char* languageModelDataPath) +void LMInstantiator::loadLanguageModel(const char* languageModelDataPath) { if (languageModelDataPath) { m_languageModel.close(); @@ -45,12 +45,12 @@ void vChewingLM::loadLanguageModel(const char* languageModelDataPath) } } -bool vChewingLM::isDataModelLoaded() +bool LMInstantiator::isDataModelLoaded() { return m_languageModel.isLoaded(); } -void vChewingLM::loadCNSData(const char* cnsDataPath) +void LMInstantiator::loadCNSData(const char* cnsDataPath) { if (cnsDataPath) { m_cnsModel.close(); @@ -58,12 +58,12 @@ void vChewingLM::loadCNSData(const char* cnsDataPath) } } -bool vChewingLM::isCNSDataLoaded() +bool LMInstantiator::isCNSDataLoaded() { return m_cnsModel.isLoaded(); } -void vChewingLM::loadUserPhrases(const char* userPhrasesDataPath, +void LMInstantiator::loadUserPhrases(const char* userPhrasesDataPath, const char* excludedPhrasesDataPath) { if (userPhrasesDataPath) { @@ -76,7 +76,7 @@ void vChewingLM::loadUserPhrases(const char* userPhrasesDataPath, } } -void vChewingLM::loadUserAssociatedPhrases(const char *userAssociatedPhrasesPath) +void LMInstantiator::loadUserAssociatedPhrases(const char *userAssociatedPhrasesPath) { if (userAssociatedPhrasesPath) { m_associatedPhrases.close(); @@ -84,7 +84,7 @@ void vChewingLM::loadUserAssociatedPhrases(const char *userAssociatedPhrasesPath } } -void vChewingLM::loadPhraseReplacementMap(const char* phraseReplacementPath) +void LMInstantiator::loadPhraseReplacementMap(const char* phraseReplacementPath) { if (phraseReplacementPath) { m_phraseReplacement.close(); @@ -92,12 +92,12 @@ void vChewingLM::loadPhraseReplacementMap(const char* phraseReplacementPath) } } -const vector vChewingLM::bigramsForKeys(const string& preceedingKey, const string& key) +const vector LMInstantiator::bigramsForKeys(const string& preceedingKey, const string& key) { return vector(); } -const vector vChewingLM::unigramsForKey(const string& key) +const vector LMInstantiator::unigramsForKey(const string& key) { if (key == " ") { vector spaceUnigrams; @@ -143,7 +143,7 @@ const vector vChewingLM::unigramsForKey(const string& key) return allUnigrams; } -bool vChewingLM::hasUnigramsForKey(const string& key) +bool LMInstantiator::hasUnigramsForKey(const string& key) { if (key == " ") { return true; @@ -156,41 +156,41 @@ bool vChewingLM::hasUnigramsForKey(const string& key) return unigramsForKey(key).size() > 0; } -void vChewingLM::setPhraseReplacementEnabled(bool enabled) +void LMInstantiator::setPhraseReplacementEnabled(bool enabled) { m_phraseReplacementEnabled = enabled; } -bool vChewingLM::phraseReplacementEnabled() +bool LMInstantiator::phraseReplacementEnabled() { return m_phraseReplacementEnabled; } -void vChewingLM::setCNSEnabled(bool enabled) +void LMInstantiator::setCNSEnabled(bool enabled) { m_cnsEnabled = enabled; } -bool vChewingLM::cnsEnabled() +bool LMInstantiator::cnsEnabled() { return m_cnsEnabled; } -void vChewingLM::setExternalConverterEnabled(bool enabled) +void LMInstantiator::setExternalConverterEnabled(bool enabled) { m_externalConverterEnabled = enabled; } -bool vChewingLM::externalConverterEnabled() +bool LMInstantiator::externalConverterEnabled() { return m_externalConverterEnabled; } -void vChewingLM::setExternalConverter(std::function externalConverter) +void LMInstantiator::setExternalConverter(std::function externalConverter) { m_externalConverter = externalConverter; } -const vector vChewingLM::filterAndTransformUnigrams(const vector unigrams, const unordered_set& excludedValues, unordered_set& insertedValues) +const vector LMInstantiator::filterAndTransformUnigrams(const vector unigrams, const unordered_set& excludedValues, unordered_set& insertedValues) { vector results; @@ -225,12 +225,12 @@ const vector vChewingLM::filterAndTransformUnigrams(const vector vChewingLM::associatedPhrasesForKey(const string& key) +const vector LMInstantiator::associatedPhrasesForKey(const string& key) { return m_associatedPhrases.valuesForKey(key); } -bool vChewingLM::hasAssociatedPhrasesForKey(const string& key) +bool LMInstantiator::hasAssociatedPhrasesForKey(const string& key) { return m_associatedPhrases.hasValuesForKey(key); } diff --git a/Source/Modules/LangModelRelated/mgrLangModel.mm b/Source/Modules/LangModelRelated/mgrLangModel.mm index 7658f3ff..e3e9b868 100644 --- a/Source/Modules/LangModelRelated/mgrLangModel.mm +++ b/Source/Modules/LangModelRelated/mgrLangModel.mm @@ -28,8 +28,8 @@ using namespace vChewing; static const int kUserOverrideModelCapacity = 500; static const double kObservedOverrideHalflife = 5400.0; -static vChewingLM gLangModelCHT; -static vChewingLM gLangModelCHS; +static LMInstantiator gLangModelCHT; +static LMInstantiator gLangModelCHS; static UserOverrideModel gUserOverrideModelCHT(kUserOverrideModelCapacity, kObservedOverrideHalflife); static UserOverrideModel gUserOverrideModelCHS(kUserOverrideModelCapacity, kObservedOverrideHalflife); @@ -41,7 +41,7 @@ static NSString *const kTemplateExtension = @".txt"; @implementation mgrLangModel -static void LTLoadLanguageModelFile(NSString *filenameWithoutExtension, vChewingLM &lm) +static void LTLoadLanguageModelFile(NSString *filenameWithoutExtension, LMInstantiator &lm) { Class cls = NSClassFromString(@"ctlInputMethod"); NSString *dataPath = [[NSBundle bundleForClass:cls] pathForResource:filenameWithoutExtension ofType:@"txt"]; @@ -317,12 +317,12 @@ static void LTLoadLanguageModelFile(NSString *filenameWithoutExtension, vChewing return [[NSBundle bundleForClass:cls] pathForResource:@"char-kanji-cns" ofType:@"txt"]; } - + (vChewingLM *)lmCHT + + (LMInstantiator *)lmCHT { return &gLangModelCHT; } -+ (vChewingLM *)lmCHS ++ (LMInstantiator *)lmCHS { return &gLangModelCHS; } diff --git a/Source/Modules/LangModelRelated/mgrLangModel_Privates.h b/Source/Modules/LangModelRelated/mgrLangModel_Privates.h index 49cd0de8..22077d25 100644 --- a/Source/Modules/LangModelRelated/mgrLangModel_Privates.h +++ b/Source/Modules/LangModelRelated/mgrLangModel_Privates.h @@ -19,13 +19,13 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH #import "mgrLangModel.h" #import "UserOverrideModel.h" -#import "vChewingLM.h" +#import "LMInstantiator.h" NS_ASSUME_NONNULL_BEGIN @interface mgrLangModel () -@property (class, readonly, nonatomic) vChewing::vChewingLM *lmCHT; -@property (class, readonly, nonatomic) vChewing::vChewingLM *lmCHS; +@property (class, readonly, nonatomic) vChewing::LMInstantiator *lmCHT; +@property (class, readonly, nonatomic) vChewing::LMInstantiator *lmCHS; @property (class, readonly, nonatomic) vChewing::UserOverrideModel *userOverrideModelCHS; @property (class, readonly, nonatomic) vChewing::UserOverrideModel *userOverrideModelCHT; @end diff --git a/vChewing.xcodeproj/project.pbxproj b/vChewing.xcodeproj/project.pbxproj index f7e2c7d7..449538b2 100644 --- a/vChewing.xcodeproj/project.pbxproj +++ b/vChewing.xcodeproj/project.pbxproj @@ -68,7 +68,7 @@ 6ACC3D442793701600F1B140 /* ParselessPhraseDB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6ACC3D402793701600F1B140 /* ParselessPhraseDB.cpp */; }; 6ACC3D452793701600F1B140 /* ParselessLM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6ACC3D422793701600F1B140 /* ParselessLM.cpp */; }; D41355D8278D74B5005E5CBD /* mgrLangModel.mm in Sources */ = {isa = PBXBuildFile; fileRef = D41355D7278D7409005E5CBD /* mgrLangModel.mm */; }; - D41355DB278E6D17005E5CBD /* vChewingLM.mm in Sources */ = {isa = PBXBuildFile; fileRef = D41355D9278E6D17005E5CBD /* vChewingLM.mm */; }; + D41355DB278E6D17005E5CBD /* LMInstantiator.mm in Sources */ = {isa = PBXBuildFile; fileRef = D41355D9278E6D17005E5CBD /* LMInstantiator.mm */; }; D41355DE278EA3ED005E5CBD /* UserPhrasesLM.mm in Sources */ = {isa = PBXBuildFile; fileRef = D41355DC278EA3ED005E5CBD /* UserPhrasesLM.mm */; }; D427F76C278CA2B0004A2160 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D427F76B278CA1BA004A2160 /* AppDelegate.swift */; }; D44FB74D2792189A003C80A6 /* PhraseReplacementMap.mm in Sources */ = {isa = PBXBuildFile; fileRef = D44FB74B2792189A003C80A6 /* PhraseReplacementMap.mm */; }; @@ -243,8 +243,8 @@ 6ACC3D432793701600F1B140 /* ParselessLM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParselessLM.h; sourceTree = ""; }; D41355D6278D7409005E5CBD /* mgrLangModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mgrLangModel.h; sourceTree = ""; }; D41355D7278D7409005E5CBD /* mgrLangModel.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = mgrLangModel.mm; sourceTree = ""; }; - D41355D9278E6D17005E5CBD /* vChewingLM.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = vChewingLM.mm; sourceTree = ""; }; - D41355DA278E6D17005E5CBD /* vChewingLM.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = vChewingLM.h; sourceTree = ""; }; + D41355D9278E6D17005E5CBD /* LMInstantiator.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = LMInstantiator.mm; sourceTree = ""; }; + D41355DA278E6D17005E5CBD /* LMInstantiator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LMInstantiator.h; sourceTree = ""; }; D41355DC278EA3ED005E5CBD /* UserPhrasesLM.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = UserPhrasesLM.mm; sourceTree = ""; }; D41355DD278EA3ED005E5CBD /* UserPhrasesLM.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UserPhrasesLM.h; sourceTree = ""; }; D427A9BF25ED28CC005D43E0 /* vChewing-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "vChewing-Bridging-Header.h"; sourceTree = ""; }; @@ -423,12 +423,12 @@ 5B62A32427AE757300A19448 /* LangModelRelated */ = { isa = PBXGroup; children = ( + D41355D9278E6D17005E5CBD /* LMInstantiator.mm */, + D41355DA278E6D17005E5CBD /* LMInstantiator.h */, D41355D6278D7409005E5CBD /* mgrLangModel.h */, D495583A27A5C6C4006ADE1C /* mgrLangModel_Privates.h */, D41355D7278D7409005E5CBD /* mgrLangModel.mm */, 5B62A32527AE758000A19448 /* SubLanguageModels */, - D41355D9278E6D17005E5CBD /* vChewingLM.mm */, - D41355DA278E6D17005E5CBD /* vChewingLM.h */, ); path = LangModelRelated; sourceTree = ""; @@ -937,7 +937,7 @@ 5B11328927B94CFB00E58451 /* AppleKeyboardConverter.swift in Sources */, 5B62A31827AE73A700A19448 /* zip.m in Sources */, 5B62A32E27AE78B000A19448 /* CNSLM.mm in Sources */, - D41355DB278E6D17005E5CBD /* vChewingLM.mm in Sources */, + D41355DB278E6D17005E5CBD /* LMInstantiator.mm in Sources */, 5B62A31A27AE73A700A19448 /* mztools.m in Sources */, 5B62A32927AE77D100A19448 /* FSEventStreamHelper.swift in Sources */, D47F7DD3278C1263002F9DD7 /* UserOverrideModel.cpp in Sources */,