OSDN Git Service

0除算例外が出ても平気にした。
authorh677 <h677>
Fri, 5 Nov 2004 14:24:26 +0000 (14:24 +0000)
committerh677 <h677>
Fri, 5 Nov 2004 14:24:26 +0000 (14:24 +0000)
GikoBayesian.pas

index c7f5606..f72a08b 100644 (file)
@@ -4,7 +4,7 @@ unit GikoBayesian;
 \file          GikoBayesian.pas
 \brief \83x\83C\83W\83A\83\93\83t\83B\83\8b\83^
 
-$Id: GikoBayesian.pas,v 1.16 2004/11/01 10:32:02 yoffy Exp $
+$Id: GikoBayesian.pas,v 1.17 2004/11/05 14:24:26 h677 Exp $
 }
 
 //! \95½\89¼\96¼\82ð\8e«\8f\91\82É\8aÜ\82ß\82È\82¢
@@ -699,10 +699,15 @@ function TGikoBayesian.CalcPaulGraham( wordCount : TWordCount ) : Extended;
                        Result := 0.01
                else if info.ImportantWord + info.NormalWord * 2 < 5 then
                        Result := 0.5
-               else
-                       Result := ( info.ImportantWord / info.ImportantText ) /
-                               ((info.NormalWord * 2 / info.NormalText ) +
-                                (info.ImportantWord / info.ImportantText));
+               else begin
+                       try
+                               Result := ( info.ImportantWord / info.ImportantText ) /
+                                       ((info.NormalWord * 2 / info.NormalText ) +
+                                        (info.ImportantWord / info.ImportantText));
+                       except
+               on EZeroDivide do Result := 0.99;
+                       end;
+               end;
        end;
 
 var