public function parseScores($debugData, $queryFields)
    {
        $highScores = [];

        /* TODO Provide better parsing
         *
         * parsing could be done line by line,
         * 		* recording indentation level
         * 		* replacing abbreviations
         * 		* replacing phrases like "product of" by mathematical symbols (* or x)
         * 		* ...
         */

        // matches search term weights, ex: 0.42218783 = (MATCH) weight(content:iPod^40.0 in 43), product of:
        $pattern = '/(.*) = weight\(([^ \)]*)/';
        $scoreMatches = [];
        preg_match_all($pattern, $debugData, $scoreMatches);

        foreach ($scoreMatches[0] as $key => $value) {
            // split field from search term
            list($field, $searchTerm) = explode(':', $scoreMatches[2][$key]);

            $currentScoreValue = $scoreMatches[1][$key];

            $scoreWasSetForFieldBefore = isset($highScores[$field]);
            $scoreIsHigher = false;
            if ($scoreWasSetForFieldBefore) {
                /** @var  $previousScore Score */
                $previousScore = $highScores[$field];
                $scoreIsHigher = $previousScore->getScore() < $currentScoreValue;
            }

            // keep track of highest score per search term
            if (!$scoreWasSetForFieldBefore || $scoreIsHigher) {
                $pattern = '/' . $field . '\^([\d.]*)/';
                $boostMatches = [];
                preg_match_all($pattern, $queryFields, $boostMatches);
                $boost = $boostMatches[1][0];
                $highScores[$field] = new Score($boost, $field, $currentScoreValue, $searchTerm);
            }
        }

        return $highScores;
    }
public function parseScores($debugData, $queryFields)
    {
        $highScores = [];

        /* TODO Provide better parsing
         *
         * parsing could be done line by line,
         * 		* recording indentation level
         * 		* replacing abbreviations
         * 		* replacing phrases like "product of" by mathematical symbols (* or x)
         * 		* ...
         */

        // matches search term weights, ex: 0.42218783 = (MATCH) weight(content:iPod^40.0 in 43), product of:
        $pattern = '/(.*) = weight\(([^ \)]*)/';
        $scoreMatches = [];
        preg_match_all($pattern, $debugData, $scoreMatches);

        foreach ($scoreMatches[0] as $key => $value) {
            // split field from search term
            list($field, $searchTerm) = explode(':', $scoreMatches[2][$key]);

            $currentScoreValue = $scoreMatches[1][$key];

            $scoreWasSetForFieldBefore = isset($highScores[$field]);
            $scoreIsHigher = false;
            if ($scoreWasSetForFieldBefore) {
                /** @var  $previousScore Score */
                $previousScore = $highScores[$field];
                $scoreIsHigher = $previousScore->getScore() < $currentScoreValue;
            }

            // keep track of highest score per search term
            if (!$scoreWasSetForFieldBefore || $scoreIsHigher) {
                $pattern = '/' . $field . '\^([\d.]*)/';
                $boostMatches = [];
                preg_match_all($pattern, $queryFields, $boostMatches);
                $boost = $boostMatches[1][0];
                $highScores[$field] = new Score($boost, $field, $currentScoreValue, $searchTerm);
            }
        }

        return $highScores;
    }
public function parseScores ( $ debugData , $ queryFields ) { $ highScores = [ ] ; /* TODO Provide better parsing
         *
         * parsing could be done line by line,
         * 		* recording indentation level
         * 		* replacing abbreviations
         * 		* replacing phrases like "product of" by mathematical symbols (* or x)
         * 		* ...
         */ // matches search term weights, ex: 0.42218783 = (MATCH) weight(content:iPod^40.0 in 43), product of: $ pattern = '/(.*) = weight\(([^ \)]*)/' ; $ scoreMatches = [ ] ; preg_match_all ( $ pattern , $ debugData , $ scoreMatches ) ; foreach ( $ scoreMatches [ 0 ] as $ key => $ value ) { // split field from search term list ( $ field , $ searchTerm ) = explode ( ':' , $ scoreMatches [ 2 ] [ $ key ] ) ; $ currentScoreValue = $ scoreMatches [ 1 ] [ $ key ] ; $ scoreWasSetForFieldBefore = isset ( $ highScores [ $ field ] ) ; $ scoreIsHigher = false ; if ( $ scoreWasSetForFieldBefore ) { /** @var  $previousScore Score */ $ previousScore = $ highScores [ $ field ] ; $ scoreIsHigher = $ previousScore -> getScore ( ) < $ currentScoreValue ; } // keep track of highest score per search term if ( ! $ scoreWasSetForFieldBefore || $ scoreIsHigher ) { $ pattern = '/' . $ field . '\^([\d.]*)/' ; $ boostMatches = [ ] ; preg_match_all ( $ pattern , $ queryFields , $ boostMatches ) ; $ boost = $ boostMatches [ 1 ] [ 0 ] ; $ highScores [ $ field ] = new Score ( $ boost , $ field , $ currentScoreValue , $ searchTerm ) ; } } return $ highScores ; }
Parses the debugData and the queryFields into an array of score objects.

@param string $debugData
@param string $queryFields
@return array[] array of Score
Parses the debugData and the queryFields into an array of score objects .