5 Windows,Messages, ShellAPI, SysUtils, Classes,StdCtrls,StrUtils;
8 TIndiviAbon = class( TObject )
11 FOption: Integer; // 0:
\93§
\96¾ 1:
\92Ê
\8fí
\82 \82Ú
\81[
\82ñ
13 property Res : Integer read FRes write FRes;
14 property Option : Integer read FOption write FOption;
17 TIndiviAbonList = class( TList )
19 FFilePath : string; //!<
\83t
\83@
\83C
\83\8b\83p
\83X
20 FLearned : Integer; //!<
\83X
\83p
\83\80\8aw
\8fK
\8dÏ
\82Ý
\83\8c\83X No
22 function GetItem( index : Integer ) : TIndiviAbon;
23 procedure SetItem( index : Integer; value : TIndiviAbon );
26 destructor Destroy; override;
28 property Items[ index : Integer ] : TIndiviAbon
29 read GetItem write SetItem; default;
30 procedure Sort; overload;
31 procedure LoadFromFile( const filePath : string );
35 TAbon = class(TObject)
41 Ftokens : array of array of string;
42 FAbonRes : TIndiviAbonList;
44 FDeleterlo : Boolean; //&rlo;
\82ð
\8dí
\82é
\82© //
\92Ç
\89Á&lro;
\82à
\8dí
\82é
45 FReplaceul :Boolean ; //<ul>
\83^
\83O
\82ð<br>
\83^
\83O
\82É
\92u
\8a·
\82·
\82é
\82©
46 FReverse : Boolean ; //NG
\83\8f\81[
\83h
\82Å
\82Ì
\82 \82Ú
\81`
\82ñ
\82Ì
\8c\8b\89Ê
\82ð
\94½
\93]
\82³
\82¹
\82é
\82©
47 FAbonPopupRes : Boolean; //
\83\8c\83X
\83|
\83b
\83v
\83A
\83b
\83v
\82Ì
\8e\9e\82É
\82 \82Ú
\81[
\82ñ
\82·
\82é
\82©
48 FNGwordFileIndex : Integer; //
\8c»
\8dÝ
\93Ç
\82Ý
\8d\9e\82ñ
\82Å
\82éNG
\83\8f\81[
\83h
\82ªlist
\82Ì
\89½
\8ds
\96Ú
\82©
49 FNGwordname : String; //
\8c»
\8dÝ
\93Ç
\82Ý
\8d\9e\82ñ
\82Å
\82éNG
\83\8f\81[
\83h
\82Ì
\95\
\8e¦
\96¼
50 FIndividualFileName : String; //
\8cÂ
\95Ê
\82 \82Ú
\81`
\82ñ
\82Ì
\83t
\83@
\83C
\83\8b\96¼
51 FReturnNGwordLineNum : Boolean; //NG
\83\8f\81[
\83h
\82Ì
\8ds
\90\94\82ð
\95Ô
\82·
\81B
52 FSetNGResAnchor : Boolean; //NG
\82É
\8aY
\93\96\82µ
\82½
\82Æ
\82«
\82É
\96{
\95¶
\82É
\82»
\82Ì
\83\8c\83X
\82Ö
\82Ì
\83\8c\83X
\83A
\83\93\83J
\81[
\82ð
\82Â
\82¯
\82é
\82©
\82Ç
\82¤
\82©
53 FDeleteSyria: Boolean; //
\83V
\83\8a\83A
\8cê
\83u
\83\89\83N
\83\89\91Î
\8dô
\81i܀~ݏ
\81j
54 procedure SetTokens(index: integer ; argline:String);
55 function Getlistpath() : String;
56 procedure Setlistpath(const Value : String);
57 function LoadListFile(path :String;listStringList : TStringList) : Boolean;
58 function ReadNGwordslist(line : Integer) : Boolean;
59 function LoadFromSetResNumFile(SetResNumFile : String) : Boolean;
62 constructor Create; //
\83R
\83\93\83X
\83g
\83\89\83N
\83^
63 destructor Destroy; override; //
\83f
\83X
\83g
\83\89\83N
\83^
64 property Deleterlo: Boolean read FDeleterlo write FDeleterlo default false;
65 property Replaceul: Boolean read FReplaceul write FReplaceul default false;
66 property Reverse: Boolean read FReverse write FReverse default false;
67 property AbonString : String read FAbonString write FAbonString;
68 property AbonPopupRes : Boolean read FAbonPopupRes write FAbonPopupRes default false;
69 property listpath : String read Getlistpath write Setlistpath;
70 property NGwordFileIndex : Integer read FNGwordFileIndex write FNGwordFileIndex default 0;
71 property NGwordname : String read FNGwordname write FNGwordname;
72 property ReturnNGwordLineNum : Boolean read FReturnNGwordLineNum write FReturnNGwordLineNum default false;
73 property SetNGResAnchor : Boolean read FSetNGResAnchor write FSetNGResAnchor default false;
74 property DeleteSyria : Boolean read FDeleteSyria write FDeleteSyria default false;
75 procedure Setroot(root :String);
76 function Getroot() : String;
78 function Getfullpath(argpath : String) : String;
79 procedure SetNGwordpath(path :String);
80 function GetNGwordpath() : String;
81 function LoadFromNGwordFile(path :String) : Boolean;
82 function ReLoadFromNGwordFile() : Boolean;
83 procedure LoadFromStringList( bufstl : TStringList );
84 function CheckAbonPopupRes(line : String) :Boolean;
85 function FindNGwords(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean;//1
\83\89\83C
\83\93\82¸
\82Â
\97p
\81B
86 //
\82 \82Ú
\81`
\82ñ
\8f\88\97\9d(NG
\83\8f\81[
\83h
\82Å
\82Ì
\83t
\83B
\83\8b\83^
\83\8a\83\93\83O)
87 procedure Execute(var ThreadStrings : TStringList); overload;
88 procedure Execute(var ResString : String; ResNumber : Integer); overload; //
\8eå
\82Éplugin
\82©
\82ç
\82ÌDat To HTML
\97p
90 //!
\83X
\83p
\83\80\83t
\83B
\83\8b\83^
\82Ì
\8aw
\8fK
91 procedure Learn( resList : TStringList );
92 //
\8cÂ
\95Ê
\82 \82Ú
\81`
\82ñ
\82µ
\82å
\82è
93 procedure IndividualAbon(var ThreadStrings : TStringList; SetResNumFile : String); overload;
94 procedure IndividualAbon(var ResString : String; SetResNumFile : String; ResNumber : Integer); overload;
95 procedure AddIndividualAbon( ResNum : Integer ; option : Integer; SetResNumFile : String);
96 function CheckIndividualAbonList(ResNum : Integer) : Boolean;
98 procedure EditNGwords(); //NGword.txt
\82ð
\8aJ
\82
\81B
99 function ShowAllTokens() : String; //
\83f
\83o
\83b
\83O
\97p
101 procedure GoHome();//List
\82Ì
\82P
\8ds
\96Ú
\82ð
\93Ç
\82Þ
102 function GoForward() : Boolean; //List
\82Ì
\88ê
\82Â
\8e\9f\82ÌNG
\83\8f\81[
\83h
\83t
\83@
\83C
\83\8b\82ð
\93Ç
\82Ý
\8d\9e\82Þ
103 function GoBack() : Boolean; //List
\82Ì
\88ê
\82Â
\91O
\82ÌNG
\83\8f\81[
\83h
\83t
\83@
\83C
\83\8b\82ð
\93Ç
\82Ý
\8d\9e\82Þ
105 function TreatSyria(AString: string): string;
110 NGwordListFileName : String = 'NGwords.list';
114 uses MojuUtils, GikoSystem, GikoBayesian, Setting;
116 function InvidiAbonListSort( item1, item2 : Pointer ) : Integer;
119 Result := TIndiviAbon( item1 ).Res - TIndiviAbon( item2 ).Res;
123 destructor TIndiviAbonList.Destroy;
128 for i := 0 to Count - 1 do
129 if inherited Items[ i ] <> nil then
130 TObject( inherited Items[ i ] ).Free;
136 function TIndiviAbonList.GetItem( index : Integer ) : TIndiviAbon;
139 Result := TIndiviAbon( inherited Items[ index ] );
143 procedure TIndiviAbonList.SetItem( index : Integer; value : TIndiviAbon );
146 inherited Items[ index ] := Pointer( value );
150 procedure TIndiviAbonList.Sort;
153 inherited Sort( InvidiAbonListSort );
157 procedure TIndiviAbonList.LoadFromFile( const filePath : string );
159 bufStringList : TStringList;
165 if not FileExists( filePath ) then begin
170 FFilePath := filePath;
171 bufStringList := TStringList.Create;
173 bufStringList.LoadFromFile( filePath );
174 if bufStringList.Values[ 'Learned' ] <> '' then begin
175 FLearned := StrToInt( bufStringList.Values[ 'Learned' ] );
176 bufStringList.Delete( bufStringList.IndexOfName( 'Learned' ) );
182 for i := bufStringList.Count-1 downto 0 do begin
183 if bufStringList.Strings[i] = '' then begin
184 bufStringList.Delete(i);
189 for i := 0 to bufStringList.Count - 1 do begin
190 bufLine := Trim(bufStringList.Strings[i]);
191 item := TIndiviAbon.Create;
192 item.Res := StrToInt(Copy(bufLine,1,AnsiPos('-',bufLine)-1));
193 item.option := StrToInt(Copy(bufLine,AnsiPos('-',bufLine)+1,1));
202 procedure TIndiviAbonList.Save;
204 bufStringList : TStringList;
208 bufStringList := TStringList.Create;
210 bufStringList.Values[ 'Learned' ] := IntToStr( FLearned );
212 for i := 0 to Count - 1 do begin
214 IntToStr( Items[ i ].Res ) + '-' + IntToStr( Items[ i ].Option ) );
217 bufStringList.SaveToFile( FFilePath );
224 constructor TAbon.Create;
227 FAbonString := ' <> <> <> <><>';
228 FAbonRes := TIndiviAbonList.Create;
232 destructor TAbon.Destroy;
237 //root
\82ÍExe\config\NGwords
\83t
\83H
\83\8b\83_
238 procedure TAbon.Setroot(root :String);
240 bufStringList : TStringList;
242 bufStringList := TStringList.Create;
244 if not DirectoryExists(root) then begin
247 if root[Length(root)] <> '\' then begin
250 Flistpath := root + NGwordListFileName;
251 LoadListFile(Flistpath, bufStringList);
257 function TAbon.Getroot() : String;
261 //NGwordpath
\82ÍNGword.txt
\82Ì
\83t
\83\8b\83p
\83X
262 procedure TAbon.SetNGwordpath(path :String);
264 FNGwordpath := Getfullpath(path);
265 LoadFromNGwordFile(FNGwordpath);
267 function TAbon.GetNGwordpath() : String;
269 Result := FNGwordpath;
271 //
\83t
\83\8b\83p
\83X
\82Å
\82È
\82¯
\82ê
\82Î
\83t
\83\8b\83p
\83X
\82É
\82µ
\82Ä
\95Ô
\82·
\81B
272 function TAbon.Getfullpath(argpath : String) : String;
274 if AnsiPos(':\',argpath) <> 2 then begin //
\83h
\83\89\83C
\83u
\82©
\82ç
\82Ì
\83t
\83\8b\83p
\83X
\82ª
\96³
\82¯
\82ê
\82Î
275 if Getroot() = '' then begin
276 Result := ''; //root
\83p
\83X
\82ª
\90Ý
\92è
\82³
\82ê
\82Ä
\82È
\82¢
\82©
\8bó
\82É
\82·
\82é
278 if (Froot[Length(Froot)] = '\') and (argpath[1] = '\') then begin //
\90æ
\93ª
\82Ì\
\82ð
\8dí
\8f\9c
281 Insert( Getroot(), argpath , 1);//root
\83p
\83X
\82ð
\91}
\93ü
289 //NGword
\83t
\83@
\83C
\83\8b\82Ì
\93Ç
\82Ý
\8d\9e\82Ý
290 function TAbon.LoadFromNGwordFile(path :String) : boolean;
292 bufstl : TStringList;
294 path := Getfullpath(path);
295 if path = '' then begin
299 bufstl := TStringList.Create;
301 if not FileExists(path) then begin
304 bufstl.SaveToFile(path);
308 bufstl.LoadFromFile(path);
309 LoadFromStringList( bufstl );
318 //NGword
\83\8a\83X
\83g
\93Ç
\82Ý
\8d\9e\82Ý
319 procedure TAbon.LoadFromStringList( bufstl : TStringList );
324 for i := bufstl.Count -1 downto 0 do begin
325 if bufstl.Strings[i] = '' then begin
329 SetLength(Ftokens,bufstl.Count);
330 for i := 0 to bufstl.Count -1 do begin
331 SetTokens(i , bufstl.Strings[i]);
338 //NGwordpath
\82ª
\8aù
\82É
\90Ý
\92è
\82³
\82ê
\82Ä
\82¢
\82é
\82Æ
\82«
\82Ì
\83\8a\83\8d\81[
\83h
\97p
\8aÖ
\90\94
339 function TAbon.ReLoadFromNGwordFile() : boolean;
341 if GetNGwordpath() ='' then begin
344 Result := LoadFromNGwordFile( GetNGwordpath() );
347 function TAbon.Getlistpath() : String;
351 procedure TAbon.Setlistpath(const Value : String);
353 Flistpath := Getfullpath(Value);
355 //
\88ê
\8ds
\82Ì
\92\86\82Ì
\83g
\81[
\83N
\83\93\82ð
\90Ø
\82è
\95ª
\82¯
\82Ä
\83Z
\83b
\83g
356 procedure TAbon.SetTokens(index: integer ; argline : String);
359 bufstl : TStringList;
365 bufstl := TStringList.Create;
367 if Length(argline) > 0 then begin
368 pos := AnsiPos(#9,argline);
369 while pos <> 0 DO begin
370 buftoken := Copy(argline,1,pos-1);
371 Delete(argline,1,pos);
372 if Length(buftoken) > 0 then begin
373 bufstl.Append(buftoken);
374 end else if ( bufstl.Count = 0 ) then begin
377 pos := AnsiPos(#9,argline);
379 if Length(argline) > 0 then begin
380 bufstl.Append(argline);
383 SetLength(Ftokens[index],ret);
384 for i := 0 to bufstl.Count - 1 do begin
385 Ftokens[index][i] := bufstl.Strings[i];
393 //Debug
\97p
\82¿
\82á
\82ñ
\82ÆNG
\83\8f\81[
\83h
\82ð
\8fE
\82¦
\82Ä
\82¢
\82é
\82©
394 function TAbon.ShowAllTokens() : String;
400 for i := 0 to High(Ftokens) do begin
401 for j := 0 to High(Ftokens[i]) do begin
402 ret := ret + Ftokens[i][j];
410 //NG
\83\8f\81[
\83h
\82ª
\8aÜ
\82Ü
\82ê
\82Ä
\82¢
\82½
\82çtrue
\82ð
\95Ô
\82µ
\81A
\82»
\82ÌNG
\83\8f\81[
\83h
\82Ì
\8ds
\90\94\82ðNGwordsLineNum
\82É
\93ü
\82ê
\82Ä
\95Ô
\82·
\81B
411 //
\82à
\82µ
\82à
\93§
\96¾
\82 \82Ú
\81`
\82ñ
\82É
\82·
\82é
\82È
\82çInbisible
\82ðtrue
\82É
\82µ
\82Ä
\95Ô
\82·
412 function TAbon.FindNGwords(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean; //1
\83\89\83C
\83\93\82¸
\82Â
\97p
\81B
421 if AnsiPos(FAbonString,line) <> 1 then begin
422 for lines := 0 to High(Ftokens) do begin
425 if Ftokens[lines][0] <> '' then begin
433 for cells := start to High(Ftokens[lines]) do begin
434 if AnsiPos(Ftokens[lines][cells],bufline) = 0 then begin
438 Delete(bufline,AnsiPos(Ftokens[lines][cells],bufline),Length(Ftokens[lines][cells]));
441 if hit = true then begin
442 NGwordsLineNum := lines + 1;
449 //
\96\96\94ö
\82Ì
\83u
\81[
\83\8b\92l
\82Ítrue
\82¾
\82Æ
\81ANG
\83\8f\81[
\83h
\82ð
\8aÜ
\82Þ
\82à
\82Ì
\82¾
\82¯
\82ð
\95Ô
\82·
\81B
450 procedure TAbon.Execute(var ThreadStrings : TStringList);
453 NGwordsLine : Integer;
457 for i:=0 to ThreadStrings.Count - 1 do begin
459 if FindNGwords(ThreadStrings.Strings[i], NGwordsLine ,invisi) <> Reverse then begin
460 if invisi = true then begin
461 ThreadStrings.Strings[i] := '';
463 if not ReturnNGwordLineNum and not SetNGResAnchor then begin
464 ThreadStrings.Strings[i] := FAbonString;
465 end else if not ReturnNGwordLineNum then begin
466 ThreadStrings.Strings[i] := Format(' <> <> <>>%d<><>',[(i+1)]);
467 end else if not SetNGResAnchor then begin
468 ThreadStrings.Strings[i] := Format(' <> <> <><B> %d
\8ds
\96Ú
\82ÌNG
\83\8f\81[
\83h
\82ª
\8aÜ
\82Ü
\82ê
\82Ä
\82¢
\82Ü
\82·
\81B</B><><>',[NGwordsLine]);
470 ThreadStrings.Strings[i] := Format(' <> <> <><B> %d
\8ds
\96Ú
\82ÌNG
\83\8f\81[
\83h
\82ª
\8aÜ
\82Ü
\82ê
\82Ä
\82¢
\82Ü
\82·
\81B</B>>%d <><>',[NGwordsLine,(i+1)]);
474 bufline := ThreadStrings.Strings[i];
475 if Deleterlo = true then begin
476 bufline := CustomStringReplace(bufline,'&rlo;','');
477 bufline := CustomStringReplace(bufline,'&lro;','');
479 if Replaceul = true then begin
480 bufline := CustomStringReplace( bufline,'<ul>','<br>' );
481 bufline := CustomStringReplace( bufline,'</ul>','<br>' );
483 if DeleteSyria = true then
484 bufline := TreatSyria(bufline);
485 ThreadStrings.Strings[i] := bufline;
489 procedure TAbon.Execute(var ResString : String; ResNumber : Integer);
491 NGwordsLine : Integer;
496 if FindNGwords(ResString, NGwordsLine ,invisi) <> Reverse then begin
497 if invisi = true then begin
500 if not ReturnNGwordLineNum and not SetNGResAnchor then begin
501 ResString := FAbonString;
502 end else if not ReturnNGwordLineNum then begin
503 ResString := Format(' <> <> <>>%d<><>',[(ResNumber)]);
504 end else if not SetNGResAnchor then begin
505 ResString := Format(' <> <> <><B> %d
\8ds
\96Ú
\82ÌNG
\83\8f\81[
\83h
\82ª
\8aÜ
\82Ü
\82ê
\82Ä
\82¢
\82Ü
\82·
\81B</B><><>',[NGwordsLine]);
507 ResString := Format(' <> <> <><B> %d
\8ds
\96Ú
\82ÌNG
\83\8f\81[
\83h
\82ª
\8aÜ
\82Ü
\82ê
\82Ä
\82¢
\82Ü
\82·
\81B</B>>%d <><>',[NGwordsLine,(ResNumber)]);
511 bufline := ResString;
512 if Deleterlo = true then begin
513 bufline := CustomStringReplace( bufline,'&rlo;','' );
514 bufline := CustomStringReplace( bufline,'&lro;','' );
516 if Replaceul = true then begin
517 bufline := CustomStringReplace( bufline,'<ul>','<br>' );
518 bufline := CustomStringReplace( bufline,'</ul>','<br>' );
520 if DeleteSyria = true then
521 bufline := TreatSyria(bufline);
522 ResString := bufline;
528 //****************************************************************************//
529 //
\8c»
\8dÝ
\83Z
\83b
\83g
\82³
\82ê
\82Ä
\82¢
\82éNGword.txt
\82ð
\8aJ
\82
530 procedure TAbon.EditNGwords();
532 ShellExecute(0 ,nil,PChar(FNGwordpath),nil,nil,SW_SHOW);
534 //
\83|
\83b
\83v
\83A
\83b
\83v
\97p
\94»
\92è
\8aÖ
\90\94
535 function TAbon.CheckAbonPopupRes(line : String) :Boolean;
540 if AbonPopupRes = true then begin
541 Result := FindNGwords(line, i ,v);
546 //
\95¡
\90\94\82ÌNG
\83\8f\81[
\83h
\83e
\83L
\83X
\83g
\82ð
\93Ç
\82Ý
\8d\9e\82Þ==============================================
547 //List
\83t
\83@
\83C
\83\8b\82ð
\93Ç
\82Ý
\8d\9e\82Þ
548 function TAbon.LoadListFile(path :String; listStringList : TStringList) : Boolean;
551 listStringList.LoadFromFile(path);
554 listStringList.Append('
\88ê
\94Ê=NGword.txt');
555 listStringList.SaveToFile(path);
559 //List
\82Ì
\88ê
\82Â
\8e\9f\82ÌNG
\83\8f\81[
\83h
\83t
\83@
\83C
\83\8b\82ð
\93Ç
\82Ý
\8d\9e\82Þ
560 function TAbon.GoForward() : Boolean;
562 FNGwordFileIndex := FNGwordFileIndex + 1;
563 Result := ReadNGwordslist(FNGwordFileIndex);
565 //List
\82Ì
\88ê
\82Â
\91O
\82ÌNG
\83\8f\81[
\83h
\83t
\83@
\83C
\83\8b\82ð
\93Ç
\82Ý
\8d\9e\82Þ
566 function TAbon.GoBack() : Boolean;
568 FNGwordFileIndex := FNGwordFileIndex -1;
569 Result := ReadNGwordslist(FNGwordFileIndex);
571 //List
\82Ì
\82P
\8ds
\96Ú
\82ð
\93Ç
\82Þ
572 procedure TAbon.GoHome();
574 FNGwordFileIndex := 0;
575 ReadNGwordslist(FNGwordFileIndex);
577 //List
\82Ìline
\8ds
\96Ú
\82ð
\93Ç
\82Þ
578 function TAbon.ReadNGwordslist(line : Integer) : Boolean;
580 liststl : TStringList;
583 liststl := TStringList.Create;
585 if LoadListFile(Flistpath,liststl) = true then begin
586 if line < 0 then begin
587 line := liststl.Count - 1;
588 FNGwordFileIndex := liststl.Count - 1;
589 end else if line > liststl.Count - 1 then begin
591 FNGwordFileIndex := 0;
593 linebuf := liststl.Strings[line];
594 FNGwordname := Copy(linebuf,1,AnsiPos('=',linebuf)-1);
595 Delete(linebuf,1,AnsiPos('=',linebuf));
596 SetNGwordpath(linebuf);
607 procedure TAbon.Learn( resList : TStringList );
610 wordCount : TWordCount;
611 spamminess : Extended;
612 indiviAbon : TIndiviAbon;
614 SPAM_THRESHOLD = 0.9;
617 if GikoSys.Setting.SpamFilterAlgorithm = gsfaNone then Exit;
619 wordCount := TWordCount.Create;
621 if (FAbonRes.FLearned = 0) and (FAbonRes.Count = 0) then begin
622 //
\8f\89\82ß
\82Ä
\82Ì
\8aw
\8fK
\82©
\82Â
\8cÂ
\95Ê
\82 \82Ú
\81`
\82ñ
\82 \82è
\82È
\82Ì
\82Å
\81A
\8b\8cver
\82©
\82ç
\82Ì
\88Ú
\8ds
\82É
\82Â
\82«
623 //
\8cÂ
\95Ê
\82 \82Ú
\81`
\82ñ
\82ð
\8eg
\82Á
\82½
\8aw
\8fK
625 for i := 0 to FAbonRes.Count - 1 do begin
626 while (j < resList.Count) and (j + 1 < FAbonRes[ j ].Res) do begin
628 GikoSys.Bayesian.CountWord( resList[ j ], wordCount );
629 GikoSys.Bayesian.Learn( wordCount, False );
632 if j < resList.Count then begin
634 GikoSys.Bayesian.CountWord( resList[ j ], wordCount );
635 GikoSys.Bayesian.Learn( wordCount, True );
640 while j < resList.Count do begin
642 GikoSys.Bayesian.CountWord( resList[ j ], wordCount );
643 GikoSys.Bayesian.Learn( wordCount, False );
647 //
\8b\8cver
\82©
\82ç
\82Ì
\88Ú
\8ds
\82Å
\82Í
\82È
\82¢
\82Ì
\82Å
\83\8c\83X
\82ð
\91S
\82Ä
\90\84\98_
\82Å
\8aw
\8fK
648 //
\81¦
\90\84\98_
\82ª
\8aÔ
\88á
\82Á
\82Ä
\82¢
\82é
\8fê
\8d\87\82Í
\83\86\81[
\83U
\82ª
\82 \82Ú
\81`
\82ñ
\82ð
\8fC
\90³
\82·
\82é
\8e\96\82Å
\8aw
\8fK
\82³
\82ê
\82é
649 for j := FAbonRes.FLearned to resList.Count - 1 do begin
651 spamminess := GikoSys.SpamParse( resList[ j ], wordCount );
652 if spamminess >= SPAM_THRESHOLD then begin
654 GikoSys.Bayesian.Learn( wordCount, True );
655 indiviAbon := TIndiviAbon.Create;
656 indiviAbon.Res := j + 1;
657 indiviAbon.Option := 1;
658 FAbonRes.Add( indiviAbon );
661 GikoSys.Bayesian.Learn( wordCount, False );
666 FAbonRes.FLearned := resList.Count;
673 GikoSys.Bayesian.Save;
677 //
\95¡
\90\94\82ÌNG
\83\8f\81[
\83h
\83e
\83L
\83X
\83g
\82ð
\93Ç
\82Ý
\8d\9e\82Þ=====
\82±
\82±
\82Ü
\82Å=================================
678 //
\8cÂ
\95Ê
\82 \82Ú
\81`
\82ñ
\8eÀ
\8ds
\8aÖ
\90\94
679 procedure TAbon.IndividualAbon(var ThreadStrings : TStringList; SetResNumFile : String);
684 f := LoadFromSetResNumFile( SetResNumFile );
685 FAbonRes.FFilePath := SetResNumFile; // Learn
\82Í
\82Å
\95Û
\91¶
\82·
\82é
\82Ì
\82Å
686 Learn( ThreadStrings );
689 for i := 0 to FAbonRes.Count - 1 do begin
690 if (FAbonRes[i].Res <= ThreadStrings.Count) and (FAbonRes[i].Res > 0) then begin
692 ThreadStrings.Strings[FAbonRes[i].Res-1] :=
693 '<font color="red">
\82 \82Ú
\81`
\82ñ
\8dÏ
\82Ý</font>' +
694 ThreadStrings.Strings[FAbonRes[i].Res-1];
696 if FAbonRes[i].option = 0 then begin
697 ThreadStrings.Strings[FAbonRes[i].Res-1] := '';
699 ThreadStrings.Strings[FAbonRes[i].Res-1] := '
\82 \82Ú
\81`
\82ñ<>
\82 \82Ú
\81`
\82ñ<>
\82 \82Ú
\81`
\82ñ<>
\82 \82Ú
\81`
\82ñ<>';
706 procedure TAbon.IndividualAbon(var ResString : String; SetResNumFile : String; ResNumber : Integer);
710 if FileExists(SetResNumFile) = true then begin
711 if LoadFromSetResNumFile(SetResNumFile) = true then begin
712 for i := 0 to FAbonRes.Count - 1 do begin
713 if FAbonRes[i].Res = ResNumber then begin
714 if FAbonRes[i].option = 0 then begin
717 ResString := '
\82 \82Ú
\81`
\82ñ<>
\82 \82Ú
\81`
\82ñ<>
\82 \82Ú
\81`
\82ñ<>
\82 \82Ú
\81`
\82ñ<>';
724 FIndividualFileName := SetResNumFile;
726 FAbonRes := TIndiviAbonList.Create;
730 //
\8cÂ
\95Ê
\82 \82Ú
\81`
\82ñ
\83t
\83@
\83C
\83\8b\93Ç
\82Ý
\8d\9e\82Ý
\8aÖ
\90\94
731 function TAbon.LoadFromSetResNumFile(SetResNumFile : String) : Boolean;
734 FIndividualFileName := SetResNumFile;
736 FAbonRes := TIndiviAbonList.Create;
737 if FileExists( SetResNumFile ) then begin
738 FAbonRes.LoadFromFile( SetResNumFile );
745 //
\8cÂ
\95Ê
\82 \82Ú
\81`
\82ñ
\83t
\83@
\83C
\83\8b\82É
\92Ç
\89Á
746 procedure TAbon.AddIndividualAbon( ResNum : Integer ; option : Integer; SetResNumFile : String);
748 IndividualFile : TStringList;
751 IndividualFile := TStringList.Create;
753 if FileExists(SetResNumFile) then begin
754 IndividualFile.LoadFromFile(SetResNumFile);
756 for j := 0 to IndividualFile.Count -1 do begin
757 if AnsiPos(IntToStr(ResNum) + '-', IndividualFile[j]) = 1 then begin
763 IndividualFile.Add(IntToStr(ResNum) + '-' + IntToStr(option))
765 IndividualFile[j] := IntToStr(ResNum) + '-' + IntToStr(option);
768 IndividualFile.Add(IntToStr(ResNum) + '-' + IntToStr(option));
770 IndividualFile.SaveToFile(SetResNumFile);
776 //
\83|
\83b
\83v
\83A
\83b
\83v
\82Ì
\94»
\92è
\97p
777 function TAbon.CheckIndividualAbonList(ResNum : Integer) : Boolean;
781 if (FAbonRes.Count > 0) and (FAbonRes[0].Res <> 0) then begin
782 for i := 0 to FAbonRes.Count - 1 do begin
783 if FAbonRes[i].Res = ResNum then begin
792 //
\83V
\83\8a\83A
\8cê
\83u
\83\89\83N
\83\89\91Î
\8dô
793 function TAbon.TreatSyria(AString: string): string;
795 //count: Integer; //(܀~ݏ)
799 pos := AnsiPos('', AString);
800 while pos <> 0 do begin
801 if StrToIntDef(Copy(AString, pos+4, 2), -1) > 0 then begin
802 if (AString[pos+6] = ';' ) or (AString[pos+6] = ' ') then begin
803 tmp := tmp + Copy(AString, 1, pos - 1);
804 Delete(AString, 1, pos+6);
805 end else if StrToIntDef(AString[pos+6], -1) = -1 then begin
806 tmp := tmp + Copy(AString, 1, pos - 1);
807 Delete(AString, 1, pos+5);
809 tmp := tmp + Copy(AString, 1, pos + 5);
810 Delete(AString, 1, pos+5);
813 tmp := tmp + Copy(AString, 1, pos + 5);
814 Delete(AString, 1, pos+5);
816 pos := AnsiPos('', AString);
818 if Length(AString) > 0 then
819 tmp := tmp + AString;
823 pos := AnsiPos('³', AString);
824 while pos <> 0 do begin
825 if StrToIntDef(Copy(AString, pos+5, 1), 0) > 2 then begin
826 if (AString[pos+6] = ';') or (AString[pos+6] = ' ') then begin
827 tmp := tmp + Copy(AString, 1, pos - 1);
828 Delete(AString, 1, pos+6);
829 end else if StrToIntDef(AString[pos+6], -1) = -1 then begin
830 tmp := tmp + Copy(AString, 1, pos - 1);
831 Delete(AString, 1, pos+5);
833 tmp := tmp + Copy(AString, 1, pos + 5);
834 Delete(AString, 1, pos+5);
837 tmp := tmp + Copy(AString, 1, pos + 5);
838 Delete(AString, 1, pos+5);
840 pos := AnsiPos('³', AString);
842 if Length(AString) > 0 then
843 tmp := tmp + AString;