commit a581679218e65d18c946a2531fcd3a7c25f8e63d Author: aboelhamd Date: Sat Jun 29 02:52:09 2019 +0200 Remove icu dependability diff --git a/src/CLExec.cpp b/src/CLExec.cpp index 29ae6cb..ecf1041 100644 --- a/src/CLExec.cpp +++ b/src/CLExec.cpp @@ -20,10 +20,9 @@ #include #include #include -#include -#include -#include #include +#include +#include #include "CLExec.h" #include "TranElemLiterals.h" @@ -121,50 +120,49 @@ map > > CLExec::loadYasmetModels( return classWeights; } -string CLExec::toLowerCase(string word, string localeId) { - icu::UnicodeString uString(word.c_str()); - string lowWord; - uString.toLower(localeId.c_str()).toUTF8String(lowWord); - return lowWord; +string CLExec::toLowerCase(string s, string localeId) { + wstring ws = UtfConverter::fromUtf8(s); + ws = StringUtils::tolower(ws); + s = UtfConverter::toUtf8(ws); + + return s; } -string CLExec::toUpperCase(string word, string localeId) { - icu::UnicodeString uString(word.c_str()); - string upWord; - uString.toUpper(localeId.c_str()).toUTF8String(upWord); - return upWord; +string CLExec::toUpperCase(string s, string localeId) { + wstring ws = UtfConverter::fromUtf8(s); + ws = StringUtils::toupper(ws); + s = UtfConverter::toUtf8(ws); + + return s; } -string CLExec::FirLetUpperCase(string word, string localeId) { - icu::UnicodeString uString(word.c_str()); - uString.toLower(localeId.c_str()); - uString.setCharAt(0, - icu::UnicodeString(uString.charAt(0)).toUpper(localeId.c_str()).charAt( - 0)); +string CLExec::FirLetUpperCase(string s, string localeId) { + wstring ws = UtfConverter::fromUtf8(s); + ws = StringUtils::tolower(ws); + ws[0] = (wchar_t) towupper(ws[0]); + s = UtfConverter::toUtf8(ws); - string upWord; - uString.toUTF8String(upWord); - return upWord; + return s; } // The result of bitwise character comparison: 0 if this contains // the same characters as text, -1 if the characters in this are // bitwise less than the characters in text, +1 if the characters // in this are bitwise greater than the characters in text. -int CLExec::compare(string word1, string word2) { - icu::UnicodeString uString1(word1.c_str()); - icu::UnicodeString uString2(word2.c_str()); +int CLExec::compare(string s1, string s2) { + wstring ws1 = UtfConverter::fromUtf8(s1); + wstring ws2 = UtfConverter::fromUtf8(s2); - return uString1.compare(uString2); + return ws1.compare(ws2); } -int CLExec::compareCaseless(string word1, string word2, string localeId) { - icu::UnicodeString uString1(word1.c_str()); - uString1.toLower(localeId.c_str()); - icu::UnicodeString uString2(word2.c_str()); - uString2.toLower(localeId.c_str()); +int CLExec::compareCaseless(string s1, string s2, string localeId) { + wstring ws1 = UtfConverter::fromUtf8(s1); + ws1 = StringUtils::tolower(ws1); + wstring ws2 = UtfConverter::fromUtf8(s2); + ws2 = StringUtils::tolower(ws2); - return uString1.compare(uString2); + return ws1.compare(ws2); } // to sort translations from best to worth by their weight diff --git a/src/CLExec.h b/src/CLExec.h index 37f6dfa..d024143 100644 --- a/src/CLExec.h +++ b/src/CLExec.h @@ -20,57 +20,28 @@ using namespace pugi; class CLExec { public: - static void - segmenter(string inFilePath, string outFilePath); - - static void - lextor(string inFilePath, string outFilePath); - - static void - biltrans(string inFilePath, string outFilePath); - - static void - interchunk(string inFilePath, string outFilePath); - - static void - postchunk(string inFilePath, string outFilePath); - - static void - transfer(string inFilePath, string outFilePath); - - static void - assignWeights(string inFilePath, string outFilePath); - - static vector - getFilesInDir(string dir); - -// static void -// runYasmet (); - static map > > loadYasmetModels(string modelsDest/*, string *localeid*/); - static void - handleDatasets(); - static string - toLowerCase(string word, string localeId); + toLowerCase(string s, string localeId); static string - toUpperCase(string word, string localeId); + toUpperCase(string s, string localeId); static string - FirLetUpperCase(string word, string localeId); + FirLetUpperCase(string s, string localeId); static int - compare(string word1, string word2); + compare(string s1, string s2); static int - compareCaseless(string word1, string word2, string localeId); + compareCaseless(string s1, string s2, string localeId); static void beamSearch(vector, float> > *beamTree, - unsigned beam, vector slTokens, vector > slTags, + unsigned beam, vector slTokens, + vector > slTags, vector ambigInfo, map > > classesWeights, string localeId);