User Tools

Site Tools


20220614
    public function calculatePercentage(ScoreSet $scoreSet, $score_type = 'positive'): float
    {
        $sentiment_to_type['positive'] = 1;
        $sentiment_to_type['neutral'] = 0;
        $sentiment_to_type['negative'] = -1;
 
        $countAllScores = $scoreSet->getScores()->count();
        $result = $this->filterScoresBySentiment($scoreSet, $sentiment_to_type[$score_type]);
        if($result > 0)
            return ($result/$countAllScores) * 100;
        return 0;
    }
20220614.txt · Last modified: 2022/06/13 23:18 by admin