@@ -82,21 +82,21 @@ string Vocab::vector2stringV2(vector<int> in)
8282 for (auto it = in.begin (); it != in.end (); it++) {
8383 string word = vocab[*it];
8484
85- // step1 空白字符不处理
85+ // step1 space character skips
8686 if (word == " <s>" || word == " </s>" || word == " <unk>" )
8787 continue ;
8888
89- // step2 将音素拼成完整的单词
89+ // step2 combie phoneme to full word
9090 {
9191 int sub_word = !(word.find (" @@" ) == string::npos);
9292
93- // 处理单词起始和中间部分
93+ // process word start and middle part
9494 if (sub_word) {
9595 combine += word.erase (word.length () - 2 );
9696 is_combining = true ;
9797 continue ;
9898 }
99- // 处理单词结束部分, combine结束
99+ // process word end part
100100 else if (is_combining) {
101101 combine += word;
102102 is_combining = false ;
@@ -105,42 +105,39 @@ string Vocab::vector2stringV2(vector<int> in)
105105 }
106106 }
107107
108- // step3 处理英文单词,单词之间需要加入空格,缩写转成大写。
108+ // step3 process english word deal with space , turn abbreviation to upper case
109109 {
110110
111- // 输入是汉字不需要处理
111+ // input word is chinese, not need process
112112 if (isChinese (word)) {
113113 words.push_back (word);
114114 is_pre_english = false ;
115115 }
116- // 输入是英文单词
116+ // input word is english word
117117 else {
118118
119- // 如果前面是汉字,不论当前是多个字母还是单个字母的单词,都不需要加空格
119+ // pre word is chinese
120120 if (!is_pre_english) {
121121 word[0 ] = word[0 ] - 32 ;
122122 words.push_back (word);
123123 pre_english_len = word.size ();
124124
125125 }
126126
127- // 如果前面是单词
127+ // pre word is english word
128128 else {
129129
130- // 单个字母的单词变大写
130+ // single letter turn to upper case
131131 if (word.size () == 1 ) {
132132 word[0 ] = word[0 ] - 32 ;
133133 }
134134
135- // 前面单词的长度是大于1的,说明当前输入不属于缩写的部分,需要和前面的单词分割开,加空格
136135 if (pre_english_len > 1 ) {
137136 words.push_back (" " );
138137 words.push_back (word);
139138 pre_english_len = word.size ();
140139 }
141- // 前面单词的长度是等于1,可能是属于缩写
142140 else {
143- // 当前长度大于1, 不可能是缩写,所以需要插入空格
144141 if (word.size () > 1 ) {
145142 words.push_back (" " );
146143 }
0 commit comments