fix Trand2Simp in front_interface.cpp

pull/3030/head
TianYuan 3 years ago
parent a6845ace6a
commit 5e1ba6d2f3

@ -41,7 +41,7 @@ int main(int argc, char** argv) {
// 繁体转简体 // 繁体转简体
std::wstring sentence_simp; std::wstring sentence_simp;
front_inst->Trand2Simp(ws_sentence, sentence_simp); front_inst->Trand2Simp(ws_sentence, &sentence_simp);
ws_sentence = sentence_simp; ws_sentence = sentence_simp;
std::string s_sentence; std::string s_sentence;

@ -178,17 +178,17 @@ int FrontEngineInterface::ReadConfFile() {
} }
int FrontEngineInterface::Trand2Simp(const std::wstring &sentence, int FrontEngineInterface::Trand2Simp(const std::wstring &sentence,
std::wstring &sentence_simp) { std::wstring *sentence_simp) {
// sentence_simp = sentence; // sentence_simp = sentence;
for (int i = 0; i < sentence.length(); i++) { for (int i = 0; i < sentence.length(); i++) {
std::wstring temp(1, sentence[i]); std::wstring temp(1, sentence[i]);
std::string sigle_word = ppspeech::wstring2utf8string(temp); std::string sigle_word = ppspeech::wstring2utf8string(temp);
// 单个字是否在繁转简的字典里 // 单个字是否在繁转简的字典里
if (trand_simp_map.find(sigle_word) == trand_simp_map.end()) { if (trand_simp_map.find(sigle_word) == trand_simp_map.end()) {
sentence_simp += temp; sentence_simp->append(temp);
} else { } else {
sentence_simp += sentence_simp->append(
(ppspeech::utf8string2wstring(trand_simp_map[sigle_word])); (ppspeech::utf8string2wstring(trand_simp_map[sigle_word])));
} }
} }

@ -43,7 +43,7 @@ class FrontEngineInterface : public TextNormalizer {
int ReadConfFile(); int ReadConfFile();
// 简体转繁体 // 简体转繁体
int Trand2Simp(const std::wstring &sentence, std::wstring &sentence_simp); int Trand2Simp(const std::wstring &sentence, std::wstring *sentence_simp);
// 生成字典 // 生成字典
int GenDict(const std::string &file, int GenDict(const std::string &file,

Loading…
Cancel
Save