@nualang/nualang-ui-components 0.1.1206 → 0.1.1207
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -248,24 +248,23 @@ function AnswerResult({
|
|
|
248
248
|
};
|
|
249
249
|
}) : [];
|
|
250
250
|
const correctWordsArray = exercise === "roleplay" ? nextScriptLine?.text?.split(" ") : currentPhrase && currentPhrase.phrase ? (0, _utils.removeExtraWhiteSpaces)(currentPhrase.phrase).split(" ") : [];
|
|
251
|
+
const handlePronunciationCheck = (word, phraseWordListIndex) => {
|
|
252
|
+
if (exercise === "pronunciation") {
|
|
253
|
+
return checkIsPronunciationCorrect(word.trim(), {
|
|
254
|
+
phrase: phraseWordList[phraseWordListIndex].trim(),
|
|
255
|
+
alternativeVersions: currentPhrase.alternativeVersions ? currentPhrase.alternativeVersions.map(altAns => {
|
|
256
|
+
return altAns ? (0, _utils.removeExtraWhiteSpaces)(altAns).split(" ")[phraseWordListIndex] : "";
|
|
257
|
+
}) : []
|
|
258
|
+
});
|
|
259
|
+
} else {
|
|
260
|
+
return checkIsPronunciationCorrect(word.trim(), phraseWordList[phraseWordListIndex].trim());
|
|
261
|
+
}
|
|
262
|
+
};
|
|
251
263
|
const transcriptArray = transcript.split(" ").map((word, i) => {
|
|
252
|
-
const isWordCorrect = phraseWordList[i] && (
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}) : []
|
|
257
|
-
}) : checkIsPronunciationCorrect(word.trim(), phraseWordList[i].trim()));
|
|
258
|
-
const isWordNearCorrect = !isWordCorrect && (phraseWordList[i - 1] && checkIsPronunciationCorrect(word.trim(), {
|
|
259
|
-
phrase: phraseWordList[i - 1].trim(),
|
|
260
|
-
alternativeVersions: currentPhrase.alternativeVersions ? currentPhrase.alternativeVersions.map(altAns => {
|
|
261
|
-
return altAns ? (0, _utils.removeExtraWhiteSpaces)(altAns).split(" ")[i - 1] : "";
|
|
262
|
-
}) : []
|
|
263
|
-
}) || phraseWordList[i + 1] && checkIsPronunciationCorrect(word.trim(), {
|
|
264
|
-
phrase: phraseWordList[i + 1].trim(),
|
|
265
|
-
alternativeVersions: currentPhrase.alternativeVersions ? currentPhrase.alternativeVersions.map(altAns => {
|
|
266
|
-
return altAns ? (0, _utils.removeExtraWhiteSpaces)(altAns).split(" ")[i + 1] : "";
|
|
267
|
-
}) : []
|
|
268
|
-
}));
|
|
264
|
+
const isWordCorrect = phraseWordList[i] && handlePronunciationCheck(word, i);
|
|
265
|
+
const isPreviousWordCorrect = !isWordCorrect && phraseWordList[i - 1] && handlePronunciationCheck(word, i - 1);
|
|
266
|
+
const isNextWordCorrect = !isWordCorrect && phraseWordList[i + 1] && handlePronunciationCheck(word, i + 1);
|
|
267
|
+
const isWordNearCorrect = !isWordCorrect && (isPreviousWordCorrect || isNextWordCorrect);
|
|
269
268
|
const wordIndex = (transcriptWords || []).findIndex(w => w.word === word.trim());
|
|
270
269
|
let wordPronunciationScore = null;
|
|
271
270
|
let wordPronunciationScorePercentage = null;
|