yooper/php-text-analysis

FreqDist::getKeyValuesByWeight

massadm opened this issue · 1 comments

$weightPerToken = $this->getWeightPerToken();
//make a copy of the array
$keyValuesByWeight = $this->keyValues;
array_walk($keyValuesByWeight, function(&$value, $key, $weightPerToken) {
$value /= $weightPerToken;
}, $this->totalTokens);

Perhaps there is a mistake.

array_walk: If the optional third parameter is supplied, it will be passed as the third parameter to the callback funcname.

So, $weightPerToken inside callback is just $this->totalTokens not $this->getWeightPerToken().

yooper commented

It has been awhile since I worked on the code base. Can you provide an example that tests the differences in your suggestion and provide the information here in this issue?

Thank you