convert method

  1. @override
String convert(
  1. String word
)
override

Converts input and returns the result of the conversion.

Implementation

@override
String convert(String word) {
  if (!word.isEmpty) {
    if (word.contains("ed", word.length - 2)) {
      RegExp reg = new RegExp(
          r'^(back|dis|for|fore|in|inter|mis|off|over|out|par|pre|re|type|un|under|up)(.+)$');
      if (reg.hasMatch(word)) {
        if (!verbsEndingWithEd.contains(reg.firstMatch(word)?.group(2)))
          return word;
      } else if (!verbsEndingWithEd.contains(word)) {
        return word;
      }
    }

    for (var r in _inflectionRules) {
      var pattern = r.first as RegExp;
      if (pattern.hasMatch(word)) {
        return word.replaceAllMapped(pattern, r.last as MatchToString);
      }
    }
  }

  return word;
}