searchWords function

Map searchWords(
  1. List<String> words
)

Takes a list of words words and returns a map containing no. of occurences and result of the word search in the arabic quran text.

You have to include the harakaat (diacritics) in the words

Example:

searchWords(["لِّلَّهِ","وَٱللَّهُ","ٱللَّهُ"])

Implementation

Map searchWords(List<String> words) {
  List<Map> result = [];

  for (var i in quranText) {
    bool exist = false;
    for (var word in words) {
      if (i['content']
          .toString()
          .toLowerCase()
          .contains(word.toString().toLowerCase())) {
        exist = true;
      }
    }
    if (exist) {
      result.add({"surah": i["surah_number"], "verse": i["verse_number"]});
    }
  }

  return {"occurences": result.length, "result": result};
}