public function scores($string)
    {
        $scores = $this->sentiment->score($string);
        $array = [];

        // The original keys are 'neg' / 'neu' / 'pos'
        // We will remap to 'negative' / 'neutral' / 'positive' and round with 2 digits
        foreach ([self::NEGATIVE, self::NEUTRAL, self::POSITIVE] as $value) {
            $array[$value] = round($scores[substr($value, 0, 3)], 2);
        }

        return $array;
    }
public function scores($string)
    {
        $scores = $this->sentiment->score($string);
        $array = [];

        // The original keys are 'neg' / 'neu' / 'pos'
        // We will remap to 'negative' / 'neutral' / 'positive' and round with 2 digits
        foreach ([self::NEGATIVE, self::NEUTRAL, self::POSITIVE] as $value) {
            $array[$value] = round($scores[substr($value, 0, 3)], 2);
        }

        return $array;
    }
public function scores ( $ string ) { $ scores = $ this -> sentiment -> score ( $ string ) ; $ array = [ ] ; // The original keys are 'neg' / 'neu' / 'pos' // We will remap to 'negative' / 'neutral' / 'positive' and round with 2 digits foreach ( [ self :: NEGATIVE , self :: NEUTRAL , self :: POSITIVE ] as $ value ) { $ array [ $ value ] = round ( $ scores [ substr ( $ value , 0 , 3 ) ] , 2 ) ; } return $ array ; }
Get scores for each decision.

@param string $string The original string

@return array An array containing keys 'negative', 'neutral' and 'positive' with a float. The closer to 1, the better

@example ['negative' => 0.5, 'neutral' => 0.25, 'positive' => 0.25]
Get scores for each decision .