sanitizeWord method
Sanitize a word by passing in the word and sanitization rules.
Implementation
String sanitizeWord(String token, String word, List<List<dynamic>> rules) {
// Empty string or doesn't need fixing.
if (token.isEmpty || _uncountables.containsKey(token)) {
return word;
}
var len = rules.length;
// Iterate over the sanitization rules and use the first one to match.
while (len-- > 0) {
final rule = rules[len];
final regexp = rule[0] as RegExp;
if (regexp.hasMatch(word)) {
return LMFeedPluralizeUtils.replace(word, rule);
}
}
return word;
}