Lets McBopomofoLM to accept NULL as the parameter in loadUserPhrases.

This commit is contained in:
zonble 2022-01-12 13:17:41 +08:00
parent 84fc2f068b
commit f1e56a7e01
3 changed files with 13 additions and 10 deletions

View File

@ -18,17 +18,23 @@ McBopomofoLM::~McBopomofoLM()
void McBopomofoLM::loadLanguageModel(const char* languageModelDataPath)
{
m_languageModel.close();
m_languageModel.open(languageModelDataPath);
if (languageModelDataPath) {
m_languageModel.close();
m_languageModel.open(languageModelDataPath);
}
}
void McBopomofoLM::loadUserPhrases(const char* userPhrasesDataPath,
const char* excludedPhrasesDataPath)
{
m_userPhrases.close();
m_userPhrases.open(userPhrasesDataPath);
m_excludedPhrases.close();
m_excludedPhrases.open(excludedPhrasesDataPath);
if (userPhrasesDataPath) {
m_userPhrases.close();
m_userPhrases.open(userPhrasesDataPath);
}
if (excludedPhrasesDataPath) {
m_excludedPhrases.close();
m_excludedPhrases.open(excludedPhrasesDataPath);
}
}
const vector<Bigram> McBopomofoLM::bigramsForKeys(const string& preceedingKey, const string& key)

View File

@ -35,7 +35,7 @@ static void LTLoadLanguageModelFile(NSString *filenameWithoutExtension, McBopomo
+ (void)loadUserPhrasesModel
{
gLanguageModelMcBopomofo.loadUserPhrases([[self userPhrasesDataPathMcBopomofo] UTF8String], [[self excludedPhrasesDataPathMcBopomofo] UTF8String]);
gLanguageModelPlainBopomofo.loadUserPhrases("", [[self excludedPhrasesDataPathPlainBopomofo] UTF8String]);
gLanguageModelPlainBopomofo.loadUserPhrases(NULL, [[self excludedPhrasesDataPathPlainBopomofo] UTF8String]);
}
+ (BOOL)checkIfUserDataFolderExists

View File

@ -2,9 +2,6 @@
// Use this file to import your target's public headers that you would like to expose to Swift.
//
//extern void LTLoadLanguageModel(void);
//extern void LTLoadUserLanguageModelFile(void);
@import Foundation;
@interface LanguageModelManager : NSObject