OSDN Git Service

- デリミタの前後で単語を区切るはずが、デリミタ前しか切っていなかったバグを修正。
authoryoffy <yoffy>
Sun, 31 Oct 2004 16:48:44 +0000 (16:48 +0000)
committeryoffy <yoffy>
Sun, 31 Oct 2004 16:48:44 +0000 (16:48 +0000)
- IndexOf の代わりに Find を使うようになった。

GikoBayesian.pas

index 51a556c..0e52a80 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.10 2004/10/31 12:24:33 yoffy Exp $
+$Id: GikoBayesian.pas,v 1.11 2004/10/31 16:48:44 yoffy Exp $
 }
 
 interface
@@ -369,11 +369,10 @@ var
        idx : Integer;
 begin
 
-       idx := IndexOf( name ); // \8c\83\92x
-       if idx < 0 then
-               Result := nil
+       if Find( name, idx ) then
+               Result := TWordInfo( inherited Objects[ idx ] )
        else
-               Result := TWordInfo( inherited Objects[ idx ] );
+               Result := nil;
 
 end;
 
@@ -385,11 +384,10 @@ var
        idx : Integer;
 begin
 
-       idx := IndexOf( name );
-       if idx < 0 then
-               AddObject( name, value )
+       if Find( name, idx ) then
+               inherited Objects[ idx ] := value
        else
-               inherited Objects[ idx ] := value;
+               AddObject( name, value );
 
 end;
 
@@ -415,8 +413,21 @@ var
        i, idx                          : Integer;
        countInfo                       : TWordCountInfo;
 const
-       KAKUJOSI = '\82ð' + #10 + '\82É' + #10 + '\82ª' + #10 + '\82Æ' + #10 + '\82©\82ç' +
-               #10 + '\82Å' + #10 + '\82Ö' + #10 + '\82æ\82è' + #10 + '\82Ü\82Å';
+       KAKUJOSI = '\82ð' + #10 + '\82É' + #10 + '\82ª' + #10 + '\82Æ' + #10 + '\82©\82ç'
+               + #10 + '\82Å' + #10 + '\82Ö' + #10 + '\82æ\82è' + #10 + '\82Ü\82Å'
+               ;{
+               + #10 + '\82±\82ê' + #10 + '\82»\82ê' + #10 + '\82 \82ê' + #10 + '\82Ç\82ê'
+               + #10 + '\82±\82Ì' + #10 + '\82»\82Ì' + #10 + '\82 \82Ì' + #10 + '\82Ç\82Ì'
+               + #10 + '\82±\82¤' + #10 + '\82»\82¤' + #10 + '\82 \82 ' + #10 + '\82Ç\82¤'
+               + #10 + '\82±\82ñ\82È' + #10 + '\82»\82ñ\82È' + #10 + '\82 \82ñ\82È' + #10 + '\82Ç\82ñ\82È'
+               + #10 + '\93I' + #10 + '\90«' + #10 + '\8e®' + #10 + '\89»' + #10 + '\96@'
+               + #10 + '\95s' + #10 + '\96³' + #10 + '\94ñ'
+               + #10 + '\82Ü\82½'
+               + #10 + '\82µ\82©\82µ' + #10 + '\82¾\82ª' + #10 + '\82¯\82Ç' + #10 + '\82¯\82ê\82Ç'
+               + #10 + '\82â\82Í\82è' + #10 + '\82â\82Á\82Ï\82è'
+               + #10 + '\82Å\82·' + #10 + '\82Ü\82·' + #10 + '\82Å\82µ' + #10 + '\82¾\82ë'
+               + #10 + '\82·\82é' + #10 + '\82µ\82È\82¢' + #10 + '\82µ\82½' + #10 + '\82µ\82È\82¢'
+               ;}
        kKanji = [$80..$A0, $E0..$ff];
 begin
 
@@ -475,22 +486,36 @@ begin
                        if (mode <> newMode) or delimited then begin
 
                                // \95\8e\9a\82Ì\83^\83C\83v\82ª\95Ï\8dX\82³\82ê\82½
-                               // \82à\82µ\82­\82Í\8bæ\90Ø\82è\82É\82È\82é\95\8e\9a\82É\91\98\8bö\82µ\82½
                                if mode <> ModeWhite then begin
                                        SetLength( aWord, p - last );
                                        CopyMemory( PChar( aWord ), last, p - last );
                                        //aWord := Copy( last, 0, p - last );
-                                       idx := wordCount.IndexOf( aWord );      // \92x
-                                       if idx < 0 then begin
+                                       if wordCount.Find( aWord, idx ) then begin
+                                               countInfo := TWordCountInfo( wordCount.Objects[ idx ] );
+                                       end else begin
                                                countInfo := TWordCountInfo.Create;
                                                wordCount.AddObject( aWord, countInfo );
-                                       end else begin
-                                               countInfo := TWordCountInfo( wordCount.Objects[ idx ] );
                                        end;
                                        countInfo.WordCount := countInfo.WordCount + 1;
                                end;
 
                                last := p;
+
+                               // \8bæ\90Ø\82è\82É\82È\82é\95\8e\9a\82É\91\98\8bö\82µ\82½
+                               if delimited then begin
+                                       SetLength( aWord, chSize );
+                                       CopyMemory( PChar( aWord ), last, chSize );
+                                       //aWord := Copy( last, 0, p - last );
+                                       if wordCount.Find( aWord, idx ) then begin
+                                               countInfo := TWordCountInfo( wordCount.Objects[ idx ] );
+                                       end else begin
+                                               countInfo := TWordCountInfo.Create;
+                                               wordCount.AddObject( aWord, countInfo );
+                                       end;
+                                       countInfo.WordCount := countInfo.WordCount + 1;
+                                       last := last + chSize;
+                               end;
+
                                mode := newMode;
 
                        end;
@@ -500,12 +525,11 @@ begin
 
                if mode <> ModeWhite then begin
                        aWord := Copy( last, 0, p - last );
-                       idx := wordCount.IndexOf( aWord );
-                       if idx < 0 then begin
+                       if wordCount.Find( aWord, idx ) then begin
+                               countInfo := TWordCountInfo( wordCount.Objects[ idx ] );
+                       end else begin
                                countInfo := TWordCountInfo.Create;
                                wordCount.AddObject( aWord, countInfo );
-                       end else begin
-                               countInfo := TWordCountInfo( wordCount.Objects[ idx ] );
                        end;
                        countInfo.WordCount := countInfo.WordCount + 1;
                end;