$segmentWordLema = $qacMasterTableEntry[$segmentId - 1]['FEATURES']['LEM'];
    $segmentWordRoot = $qacMasterTableEntry[$segmentId - 1]['FEATURES']['ROOT'];
    $verseLocation = substr($location, 0, strlen($location) - 2);
    //$segmentWord = removeTashkeel($segmentWord);
    // get word index in verse
    $wordIndex = getWordIndexFromQACLocation($location);
    // get simple version of the word index
    $imla2yWordIndex = getImla2yWordIndexByUthmaniLocation($location);
    // get verse text
    $verseText = getVerseByQACLocation($QURAN_TEXT, $location);
    //echoN($verseText);
    //echoN($segmentWord);
    $initialsSegmentsCountArr[$segmentWord]++;
    $initialsSegmentsArr[$location] = $segmentWord;
    $initialsVersesArr[$location] = $verseText;
    $verseText = removePauseMarkFromVerse($verseText);
    $wordsArr = explode(" ", $verseText);
    $initialsVersesWordsArr = array_merge($wordsArr, $initialsVersesWordsArr);
}
$initialsVersesWordsArr = array_count_values($initialsVersesWordsArr);
//echoN(count($initialsVersesArr));
//preprint_r($initialsVersesArr);
$uniqueChapters = array();
foreach ($initialsSegmentsArr as $location => $segmentWord) {
    $locationArr = explode(":", $location);
    $sura = $locationArr[0];
    $aya = $locationArr[1];
    $uniqueChapters[$sura] = 1;
    $suraVerseArr[] = array($sura, $aya, $segmentWord);
}
$suraVerseDistributionChartJSON = json_encode($suraVerseArr);
function searchResultsToWordcloud($searchResultTextArr, $lang, $maxItems)
{
    global $MODEL_CORE;
    $wordCloudArr = array();
    foreach ($searchResultTextArr as $index => $text) {
        if ($lang == "AR") {
            $text = removePauseMarkFromVerse($text);
        }
        $textWordsArr = preg_split("/ /", $text);
        foreach ($textWordsArr as $word) {
            if ($lang == "EN") {
                $word = cleanAndTrim($word);
                $word = strtolower($word);
            }
            if (empty($word)) {
                continue;
            }
            if (isset($MODEL_CORE['STOP_WORDS'][$word])) {
                continue;
            }
            $wordCloudArr[$word]++;
        }
    }
    arsort($wordCloudArr);
    $wordCloudArr = array_slice($wordCloudArr, 0, $maxItems);
    return $wordCloudArr;
}