DavidBelicza / PHP-Science-TextRank

:zap: :elephant: TextRank (resource-efficient and low-cost automatic text summarisation) for PHP
https://php.science/textrank/
MIT License
243 stars 40 forks source link

Division by zero #4

Closed vincentsch closed 6 years ago

vincentsch commented 6 years ago

src/Tool/Score.php: protected function normalize(int $value, int $min, int $max): float { $normalized = ($value - $min) / ($max - $min); return $normalized; }

When $max and $min have the same value there's a division by zero.

khalwat commented 6 years ago

I'm running into this as well when attempting to do something simple like:

$api->getOnlyKeyWords("Nothing to look at here");
khalwat commented 6 years ago

Looks to be fixed via: https://github.com/nexxome/PHP-Science-TextRank/commit/79558be89a381102346fbcdacbb534dd1cd2bbea

DavidBelicza commented 6 years ago

@vincentsch @khalwat thank for the report. I'll fix it soon.

DavidBelicza commented 6 years ago

Fixed in the last release: 1.0.4, https://github.com/DavidBelicza/PHP-Science-TextRank/releases/tag/1.0.4