Commit ·
5edf762
1
Parent(s): ccad736
Upload 2 files
Browse files- ChatIPC.cpp +5 -5
ChatIPC.cpp
CHANGED
|
@@ -1105,8 +1105,8 @@ static void skip_json_value(const std::string &s, size_t &i){
|
|
| 1105 |
}
|
| 1106 |
|
| 1107 |
static std::vector<DictionaryEntry> parse_dictionary_json(){
|
| 1108 |
-
std::vector<DictionaryEntry>
|
| 1109 |
-
if (dictionary_json_len == 0) return
|
| 1110 |
|
| 1111 |
std::string text;
|
| 1112 |
text.reserve(dictionary_json_len);
|
|
@@ -1116,7 +1116,7 @@ static std::vector<DictionaryEntry> parse_dictionary_json(){
|
|
| 1116 |
|
| 1117 |
size_t i = 0;
|
| 1118 |
skip_spaces(text, i);
|
| 1119 |
-
if (!json_valid_index(i, text.size()) || text[i] != '[') return
|
| 1120 |
++i;
|
| 1121 |
|
| 1122 |
while (true){
|
|
@@ -1160,14 +1160,14 @@ static std::vector<DictionaryEntry> parse_dictionary_json(){
|
|
| 1160 |
if (json_valid_index(i, text.size()) && text[i] == '}'){ ++i; break; }
|
| 1161 |
}
|
| 1162 |
|
| 1163 |
-
if (!entry.word.empty())
|
| 1164 |
|
| 1165 |
skip_spaces(text, i);
|
| 1166 |
if (json_valid_index(i, text.size()) && text[i] == ','){ ++i; continue; }
|
| 1167 |
if (json_valid_index(i, text.size()) && text[i] == ']'){ ++i; break; }
|
| 1168 |
}
|
| 1169 |
|
| 1170 |
-
return
|
| 1171 |
}
|
| 1172 |
|
| 1173 |
static std::string best_candidate_by_similarity(
|
|
|
|
| 1105 |
}
|
| 1106 |
|
| 1107 |
static std::vector<DictionaryEntry> parse_dictionary_json(){
|
| 1108 |
+
std::vector<DictionaryEntry> dictionary;
|
| 1109 |
+
if (dictionary_json_len == 0) return dictionary;
|
| 1110 |
|
| 1111 |
std::string text;
|
| 1112 |
text.reserve(dictionary_json_len);
|
|
|
|
| 1116 |
|
| 1117 |
size_t i = 0;
|
| 1118 |
skip_spaces(text, i);
|
| 1119 |
+
if (!json_valid_index(i, text.size()) || text[i] != '[') return dictionary;
|
| 1120 |
++i;
|
| 1121 |
|
| 1122 |
while (true){
|
|
|
|
| 1160 |
if (json_valid_index(i, text.size()) && text[i] == '}'){ ++i; break; }
|
| 1161 |
}
|
| 1162 |
|
| 1163 |
+
if (!entry.word.empty()) dictionary.push_back(std::move(entry));
|
| 1164 |
|
| 1165 |
skip_spaces(text, i);
|
| 1166 |
if (json_valid_index(i, text.size()) && text[i] == ','){ ++i; continue; }
|
| 1167 |
if (json_valid_index(i, text.size()) && text[i] == ']'){ ++i; break; }
|
| 1168 |
}
|
| 1169 |
|
| 1170 |
+
return dictionary;
|
| 1171 |
}
|
| 1172 |
|
| 1173 |
static std::string best_candidate_by_similarity(
|