|
|
@@ -5266,10 +5266,13 @@ export async function GetMiaoguoTestExamine(ctx) {
|
|
5266
|
5266
|
result = await hanzi.GetHanziUnitWords(param);
|
|
5267
|
5267
|
}
|
|
5268
|
5268
|
|
|
|
5269
|
+ //用 MiaoguoLiteracy 中的标准拼音纠正多音字与轻声(如 勒紧 的“勒”读 lēi,石榴 的“榴”读 liu)
|
|
|
5270
|
+ await fixWordsPinyinByLiteracy(result);
|
|
|
5271
|
+
|
|
5269
|
5272
|
for (const item of result) {
|
|
5270
|
5273
|
if (item.Pinyin) {
|
|
5271
|
5274
|
item.Pinyin = item.Pinyin.split(",")[0];
|
|
5272
|
|
- item.CombineWords2 = stringUtils.ReplaceAllString(item.CombineWords, item.Name, item.Pinyin);
|
|
|
5275
|
+ item.CombineWords2 = stringUtils.ReplaceAllString(item.CombineWords, item.Name, item.PinyinInWord || item.Pinyin);
|
|
5273
|
5276
|
if (item.CombineWords.length == 2 && item.CombineWords[0] == item.CombineWords[1]) {
|
|
5274
|
5277
|
switch (item.CombineWords) {
|
|
5275
|
5278
|
case "妈妈":
|
|
|
@@ -6111,6 +6114,59 @@ function getEF(EF, Q) {
|
|
6111
|
6114
|
return result;
|
|
6112
|
6115
|
}
|
|
6113
|
6116
|
|
|
|
6117
|
+//用 MiaoguoLiteracy 中的标准拼音,纠正汉字在词语里的读音(多音字、轻声)
|
|
|
6118
|
+//如:勒紧 的“勒”应为 lēi,石榴 的“榴”应为 liu
|
|
|
6119
|
+async function fixWordsPinyinByLiteracy(words) {
|
|
|
6120
|
+ if (!words || words.length === 0)
|
|
|
6121
|
+ return;
|
|
|
6122
|
+
|
|
|
6123
|
+ const wordList = [];
|
|
|
6124
|
+ for (const item of words) {
|
|
|
6125
|
+ if (!item.CombineWords)
|
|
|
6126
|
+ continue;
|
|
|
6127
|
+ for (const word of String(item.CombineWords).split(",")) {
|
|
|
6128
|
+ if (word && wordList.indexOf(word) < 0)
|
|
|
6129
|
+ wordList.push(word);
|
|
|
6130
|
+ }
|
|
|
6131
|
+ }
|
|
|
6132
|
+ if (wordList.length === 0)
|
|
|
6133
|
+ return;
|
|
|
6134
|
+
|
|
|
6135
|
+ const pinyinMap = await hanzi.GetMiaoguoLiteracyPinyin({ Words: wordList.join("','") });
|
|
|
6136
|
+ for (const item of words) {
|
|
|
6137
|
+ if (!item.CombineWords || !item.Pinyin || !item.Name)
|
|
|
6138
|
+ continue;
|
|
|
6139
|
+ for (const word of String(item.CombineWords).split(",")) {
|
|
|
6140
|
+ const arrPinyin = pinyinMap[word];
|
|
|
6141
|
+ if (!arrPinyin || arrPinyin.length !== word.length)
|
|
|
6142
|
+ continue;
|
|
|
6143
|
+ //完全没有声调的脏数据不采信(如 毛泽东 被记为 “mao ze dong”)
|
|
|
6144
|
+ if (!/[āáǎàōóǒòēéěèīíǐìūúǔùǖǘǚǜ]/.test(arrPinyin.join("")))
|
|
|
6145
|
+ continue;
|
|
|
6146
|
+ const index = word.indexOf(item.Name);
|
|
|
6147
|
+ if (index < 0 || word.lastIndexOf(item.Name) !== index)
|
|
|
6148
|
+ continue;
|
|
|
6149
|
+ const pinyinInWord = arrPinyin[index];
|
|
|
6150
|
+ if (!pinyinInWord || pinyinInWord == item.Pinyin)
|
|
|
6151
|
+ continue;
|
|
|
6152
|
+ //轻声只会出现在词尾,非词尾却没有声调的数据不采信(如 吾国 被记为 “wu guó”)
|
|
|
6153
|
+ if (index !== word.length - 1 && !/[āáǎàōóǒòēéěèīíǐìūúǔùǖǘǚǜ]/.test(pinyinInWord))
|
|
|
6154
|
+ continue;
|
|
|
6155
|
+ item.PinyinInWord = pinyinInWord;
|
|
|
6156
|
+ //多音字:词语中的读音本来就是该字的读音之一,则字本身的读音也采用词语中的读音
|
|
|
6157
|
+ const arrReading = String(item.Pinyin).split(",");
|
|
|
6158
|
+ if (arrReading.length > 1 && arrReading.indexOf(pinyinInWord) > 0)
|
|
|
6159
|
+ item.Pinyin = pinyinInWord;
|
|
|
6160
|
+ break;
|
|
|
6161
|
+ }
|
|
|
6162
|
+ }
|
|
|
6163
|
+}
|
|
|
6164
|
+
|
|
|
6165
|
+function getPinyinNormalText(pinyin) {
|
|
|
6166
|
+ const result = getPinyinNormal(pinyin);
|
|
|
6167
|
+ return result ? result : pinyin;
|
|
|
6168
|
+}
|
|
|
6169
|
+
|
|
6114
|
6170
|
function getWordJSON(param, words) {
|
|
6115
|
6171
|
const taskList = [];
|
|
6116
|
6172
|
if (words[0].Pinyin) {
|
|
|
@@ -6125,9 +6181,10 @@ function getWordJSON(param, words) {
|
|
6125
|
6181
|
],
|
|
6126
|
6182
|
};
|
|
6127
|
6183
|
taskInfo.Word = word.Name;
|
|
6128
|
|
- const pinyinNormal = "(" + getPinyinNormal(word.Pinyin) + ")";
|
|
6129
|
|
- const combineWords = stringUtils.ReplaceAllString(word.CombineWords, word.Name, word.Name + pinyinNormal);
|
|
6130
|
|
- taskInfo.ReadString = word.Name + pinyinNormal + "," + combineWords + "的" + word.Name + pinyinNormal;
|
|
|
6184
|
+ const pinyinNormal = "(" + getPinyinNormalText(word.Pinyin) + ")";
|
|
|
6185
|
+ const pinyinNormalInWord = "(" + getPinyinNormalText(word.PinyinInWord || word.Pinyin) + ")";
|
|
|
6186
|
+ const combineWords = stringUtils.ReplaceAllString(word.CombineWords, word.Name, word.Name + pinyinNormalInWord);
|
|
|
6187
|
+ taskInfo.ReadString = word.Name + pinyinNormal + "," + combineWords + "的" + word.Name + pinyinNormalInWord;
|
|
6131
|
6188
|
|
|
6132
|
6189
|
if (param.TestType == "read") {
|
|
6133
|
6190
|
taskInfo.Content[0].Content = ["怎么念"];
|