refactor(vocab): unify text normalization across VocabService and VocabPracticeDialog
All checks were successful
Deploy to production / deploy (push) Successful in 3m3s
All checks were successful
Deploy to production / deploy (push) Successful in 3m3s
- Enhanced text normalization methods in VocabService and VocabPracticeDialog to include normalization and improved regex for punctuation and symbols, ensuring consistent text handling. - This update streamlines the normalization process, contributing to better user input processing and overall application reliability.
This commit is contained in:
@@ -342,12 +342,14 @@ export default class VocabService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_normalizeTextAnswer(text) {
|
_normalizeTextAnswer(text) {
|
||||||
return String(text || '')
|
const normalized = String(text || '')
|
||||||
.trim()
|
.trim()
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.replace(/[\p{P}]+/gu, ' ')
|
.normalize('NFKC')
|
||||||
|
.replace(/[\p{P}\p{S}]+/gu, ' ')
|
||||||
.replace(/\s+/g, ' ')
|
.replace(/\s+/g, ' ')
|
||||||
.trim();
|
.trim();
|
||||||
|
return normalized.replace(/\s+/g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
_parseExercisePayload(value) {
|
_parseExercisePayload(value) {
|
||||||
|
|||||||
@@ -224,10 +224,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
normalize(s) {
|
normalize(s) {
|
||||||
return String(s || '')
|
const normalized = String(s || '')
|
||||||
.trim()
|
.trim()
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.replace(/\s+/g, ' ');
|
.normalize('NFKC')
|
||||||
|
.replace(/[\p{P}\p{S}]+/gu, ' ')
|
||||||
|
.replace(/\s+/g, ' ')
|
||||||
|
.trim();
|
||||||
|
return normalized.replace(/\s+/g, '');
|
||||||
},
|
},
|
||||||
resetQuestion() {
|
resetQuestion() {
|
||||||
this.current = null;
|
this.current = null;
|
||||||
|
|||||||
@@ -2701,12 +2701,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
normalizeComparableText(value) {
|
normalizeComparableText(value) {
|
||||||
return String(value || '')
|
const normalized = String(value || '')
|
||||||
.trim()
|
.trim()
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.replace(/[\p{P}]+/gu, ' ')
|
.normalize('NFKC')
|
||||||
|
.replace(/[\p{P}\p{S}]+/gu, ' ')
|
||||||
.replace(/\s+/g, ' ')
|
.replace(/\s+/g, ' ')
|
||||||
.trim();
|
.trim();
|
||||||
|
return normalized.replace(/\s+/g, '');
|
||||||
},
|
},
|
||||||
normalizeVocab(s) {
|
normalizeVocab(s) {
|
||||||
return this.normalizeComparableText(s);
|
return this.normalizeComparableText(s);
|
||||||
|
|||||||
Reference in New Issue
Block a user