checkQuestion method

bool checkQuestion({
  1. required String question,
  2. required Keyword keyword,
})

Implementation

bool checkQuestion({required String question, required Keyword keyword}) {
  List<List<String>> stemmedKeywords = [];

  keyword.patterns.cast<List>().forEach((element) => stemmedKeywords
      .add(element.map((word) => _stemmer.stem(word.toString())).toList()));

  final questionListStemmed = question
      .split(_wordSplitter)
      .where((word) => !stopWords.contains(word))
      .map((word) => _stemmer.stem(word))
      .toList();

  var entryScore = questionListStemmed.length;

  for (List<String> keywordList in stemmedKeywords) {
    questionListStemmed.removeWhere((word) => keywordList.contains(word));
  }

  return entryScore - questionListStemmed.length >= keyword.score;
}