getPercentageMatched function

int getPercentageMatched (
  1. String sentence,
  2. String toCheck,
  3. {bool ignoreArticles: false,
  4. bool matchCaseInsensitively: true,
  5. bool ignoreSpecialCharacters: true}
)

Returns the percentage toCheck matched against sentence.

Implementation

int getPercentageMatched(String sentence, String toCheck,
    {bool ignoreArticles = false,
    bool matchCaseInsensitively = true,
    bool ignoreSpecialCharacters = true}) {
  int match = countWordsMatched(sentence, toCheck,
      ignoreArticles: ignoreArticles,
      matchCaseInsensitively: matchCaseInsensitively,
      ignoreSpecialCharacters: ignoreSpecialCharacters);
  if (ignoreArticles) {
    sentence = removeArticles(sentence);
  }
  return _calculatePercentage(match, sentence.split(' ').length);
}