Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.1

Bug #4490 Divide by zero error
Submitted: 2005-05-31 19:44 UTC
From: mjohnson at pitsco dot com Assigned: cweiske
Status: Closed Package: Text_Statistics
PHP Version: Irrelevant OS: All
Roadmaps: (Not assigned)    
Subscription  


 [2005-05-31 19:44 UTC] mjohnson at pitsco dot com
Description: ------------ Using version 1.0, I get a divide by zero error when passing a string that has no end-of-sentence punctuation. Also, an empty string elicits an extra divide by zero error. A couple of approaches could be used to fix this. First, suppress the errors using the @ operator. Second, explicitly detect possible divide by zero conditions and either return some null value or force it to divide by one. Any solution would be viable. However, given the way the class works, either supressing the error or dividing by one is probably best. Reproduce code: --------------- $x = new Text_Statistics(''); $y = new Text_Statistics('Four score and seven years ago'); echo $x->flesch . "\n"; echo $y->flesch . "\n"; Expected result: ---------------- 205.82 87.945 -or- 206.835 94.035 (either one is acceptable, since it's not a complete sentence) Actual result: -------------- Warning: Division by zero in /usr/share/php/Text/Statistics.orig.php on line 138 Warning: Division by zero in /usr/share/php/Text/Statistics.orig.php on line 139 Warning: Division by zero in /usr/share/php/Text/Statistics.orig.php on line 138 206.835 94.035

Comments

 [2007-03-27 12:44 UTC] cweiske (Christian Weiske)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.