| | |
| | | } |
| | | } |
| | | |
| | | string Vocab::Vector2String(vector<int> in) |
| | | void Vocab::Vector2String(vector<int> in, std::vector<std::string> &preds) |
| | | { |
| | | int i; |
| | | stringstream ss; |
| | | for (auto it = in.begin(); it != in.end(); it++) { |
| | | ss << vocab[*it]; |
| | | string word = vocab[*it]; |
| | | preds.emplace_back(word); |
| | | } |
| | | return ss.str(); |
| | | } |
| | | |
| | | int Str2Int(string str) |
| | |
| | | else { |
| | | // pre word is chinese |
| | | if (!is_pre_english) { |
| | | word[0] = word[0] - 32; |
| | | // word[0] = word[0] - 32; |
| | | words.push_back(word); |
| | | pre_english_len = word.size(); |
| | | |
| | | } |
| | | // pre word is english word |
| | | else { |
| | | // single letter turn to upper case |
| | | if (word.size() == 1) { |
| | | word[0] = word[0] - 32; |
| | | } |
| | | // if (word.size() == 1) { |
| | | // word[0] = word[0] - 32; |
| | | // } |
| | | |
| | | if (pre_english_len > 1) { |
| | | words.push_back(" "); |