private function weighQueryText($subject, $complete, array $words, $max)
    {
        $lowSubject = mb_strtolower(trim($subject));

        if ($lowSubject === $complete) {
            // a complete match is 100% of the maximum
            return round((100 / 100) * $max);
        }
        if (strpos($lowSubject, $complete) !== false) {
            // when the whole query is found somewhere is 70% of the maximum
            return round((70 / 100) * $max);
        }

        $wordMatches = 0;
        $cntWords = count($words);
        foreach (array_keys($words) as $k) {
            if (strpos($lowSubject, $words[$k]) !== false) {
                ++$wordMatches;
            }
        }
        if ($wordMatches > 0) {
            // marcel: word matches are maximum of 50% of the maximum per word
            // xiao: made (100/100) instead of (50/100).
            return round(($wordMatches / $cntWords) * (100 / 100) * $max);
        }

        return 0;
    }