Division by zero
formigone opened this issue · 3 comments
formigone commented
NlpTools\Similarity\CosineSimilarity::similarity() can divide by zero if $v1_norm or $v2_norm (or both) are equal to zero.
angeloskath commented
That is true.
What do you suggest to remedy this? RuntimeException ? InvalidArgumentException? return 0?
It currently returns false and issues a warning.
yooper commented
It should throw a UnexpectedValueException. I will work on this next.
angeloskath commented
UnexpectedValueException php.net
Typically this happens when a function calls another function and expects the return value to be of a certain type or value not including arithmetic or buffer related errors
So I am guessing InvalidArgumentException.