countWordsMatchedIn function

List<WordsMatch> countWordsMatchedIn (
  1. List<String> sentences,
  2. String matchFor,
  3. {bool ignoreArticles: false,
  4. bool matchCaseInsensitively: true,
  5. bool ignoreSpecialCharacters: true}
)

Returns how many words each item in sentences matched in matchFor.

Implementation

List<WordsMatch> countWordsMatchedIn(List<String> sentences, String matchFor,
    {bool ignoreArticles = false,
    bool matchCaseInsensitively = true,
    bool ignoreSpecialCharacters = true}) {
  var matches = <WordsMatch>[];
  for (var sentence in sentences) {
    var modifiedSentence = sentence;
    if (ignoreArticles) {
      modifiedSentence = removeArticles(sentence);
    }
    matches.add(WordsMatch(
        sentence,
        countWordsMatched(modifiedSentence, matchFor,
            ignoreArticles: ignoreArticles,
            matchCaseInsensitively: matchCaseInsensitively,
            ignoreSpecialCharacters: ignoreSpecialCharacters)));
  }
  return matches;
}