correctWord method
Implementation
String? correctWord(List<String> expectedWords, {bool safetyBack = false}) {
/// define zero initial and increase when add similar from word
/// this is same with confidence in AI
double highestSimilarity = 0.0;
String closestWord = this;
for (final word in expectedWords) {
final double similarity = similarityTo(word);
if (similarity > highestSimilarity) {
highestSimilarity = similarity;
closestWord = word;
}
}
if (!safetyBack && highestSimilarity < 0.5) {
return null;
}
return closestWord;
}