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;
    }
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;
    }
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 ; }
Weight a text part relative to some other part.

@param string $subject  the subject to search in
@param string $complete the complete search term (lowercased)
@param array  $words    all the individual search terms (lowercased)
@param int    $max      maximum number of points to return

@return int The weight
Weight a text part relative to some other part .