Skip to content

Commit

Permalink
performance improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
fieg committed Aug 25, 2014
1 parent a99d11a commit e9bbc12
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/Fieg/Bayes/Classifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,15 @@ public function reset()
*/
protected function inversedTokenCount($token, $label)
{
$total = 0;
$data = $this->data;

unset($data[$label]);
$totalTokenCount = $this->tokens[$token];

foreach ($data as $_label => $tokenCounts) {
$total += intval(@$tokenCounts[$token]);
}
$totalLabelTokenCount = intval(@$data[$label][$token]);

$retval = $totalTokenCount - $totalLabelTokenCount;

return $total;
return $retval;
}

/**
Expand Down

0 comments on commit e9bbc12

Please sign in to comment.