2 NO_ABON
\82 \82Ú
\81[
\82ñ
\8dÏ
\82Ý
\82Ì
\83\8c\83X
\82à
\95\
\8e¦
\82·
\82é(
\8b
\92²
\82³
\82ê
\82é)
3 SPAM_FILTER_ENABLED
\83X
\83p
\83\80\83t
\83B
\83\8b\83^
\82ð
\8b@
\94\
\82³
\82¹
\82é
10 Windows,Messages, ShellAPI, SysUtils, Classes,StdCtrls,StrUtils,
11 Forms, Controls, AbonInfo;
14 TIndiviAbon = class( TObject )
17 FOption: Integer; // 0:
\93§
\96¾ 1:
\92Ê
\8fí
\82 \82Ú
\81[
\82ñ
19 property Res : Integer read FRes write FRes;
20 property Option : Integer read FOption write FOption;
23 TIndiviAbonList = class( TList )
25 FFilePath : string; //!<
\83t
\83@
\83C
\83\8b\83p
\83X
26 FLearned : Integer; //!<
\83X
\83p
\83\80\8aw
\8fK
\8dÏ
\82Ý
\83\8c\83X No
28 function GetItem( index : Integer ) : TIndiviAbon;
29 procedure SetItem( index : Integer; value : TIndiviAbon );
32 destructor Destroy; override;
34 property Items[ index : Integer ] : TIndiviAbon
35 read GetItem write SetItem; default;
36 procedure Sort; overload;
37 procedure LoadFromFile( const filePath : string );
41 TAbon = class(TObject)
47 Ftokens : array of array of string;
48 FAbonRes : TIndiviAbonList;
52 FDeleterlo : Boolean; //&rlo;
\82ð
\8dí
\82é
\82© //
\92Ç
\89Á&lro;
\82à
\8dí
\82é
53 FReplaceul :Boolean ; //<ul>
\83^
\83O
\82ð<br>
\83^
\83O
\82É
\92u
\8a·
\82·
\82é
\82©
54 FReverse : Boolean ; //NG
\83\8f\81[
\83h
\82Å
\82Ì
\82 \82Ú
\81`
\82ñ
\82Ì
\8c\8b\89Ê
\82ð
\94½
\93]
\82³
\82¹
\82é
\82©
55 FAbonPopupRes : Boolean; //
\83\8c\83X
\83|
\83b
\83v
\83A
\83b
\83v
\82Ì
\8e\9e\82É
\82 \82Ú
\81[
\82ñ
\82·
\82é
\82©
56 FNGwordFileIndex : Integer; //
\8c»
\8dÝ
\93Ç
\82Ý
\8d\9e\82ñ
\82Å
\82éNG
\83\8f\81[
\83h
\82ªlist
\82Ì
\89½
\8ds
\96Ú
\82©
57 FNGwordname : String; //
\8c»
\8dÝ
\93Ç
\82Ý
\8d\9e\82ñ
\82Å
\82éNG
\83\8f\81[
\83h
\82Ì
\95\
\8e¦
\96¼
58 FIndividualFileName : String; //
\8cÂ
\95Ê
\82 \82Ú
\81`
\82ñ
\82Ì
\83t
\83@
\83C
\83\8b\96¼
59 FReturnNGwordLineNum : Boolean; //NG
\83\8f\81[
\83h
\82Ì
\8ds
\90\94\82ð
\95Ô
\82·
\81B
60 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©
61 FDeleteSyria: Boolean; //
\83V
\83\8a\83A
\8cê
\83u
\83\89\83N
\83\89\91Î
\8dô
\81i܀~ݏ
\81j
62 FIgnoreKana: Boolean; //
\91S
\8ap
\94¼
\8ap
\82Ð
\82ç
\82ª
\82È
\83J
\83^
\83J
\83i
\82Ì
\88á
\82¢
\82ð
\96³
\8e\8b\82·
\82é
\82©
63 procedure SetTokens(index: integer ; argline:String);
64 function Getlistpath() : String;
65 procedure Setlistpath(const Value : String);
66 function LoadListFile(path :String;listStringList : TStringList) : Boolean;
67 function ReadNGwordslist(line : Integer) : Boolean;
68 function LoadFromSetResNumFile(SetResNumFile : String) : Boolean;
71 constructor Create; //
\83R
\83\93\83X
\83g
\83\89\83N
\83^
72 destructor Destroy; override; //
\83f
\83X
\83g
\83\89\83N
\83^
73 property Deleterlo: Boolean read FDeleterlo write FDeleterlo default false;
74 property Replaceul: Boolean read FReplaceul write FReplaceul default false;
75 property Reverse: Boolean read FReverse write FReverse default false;
76 property AbonString : String read FAbonString write FAbonString;
77 property AbonPopupRes : Boolean read FAbonPopupRes write FAbonPopupRes default false;
78 property listpath : String read Getlistpath write Setlistpath;
79 property NGwordFileIndex : Integer read FNGwordFileIndex write FNGwordFileIndex default 0;
80 property NGwordname : String read FNGwordname write FNGwordname;
81 property ReturnNGwordLineNum : Boolean read FReturnNGwordLineNum write FReturnNGwordLineNum default false;
82 property SetNGResAnchor : Boolean read FSetNGResAnchor write FSetNGResAnchor default false;
83 property DeleteSyria : Boolean read FDeleteSyria write FDeleteSyria default false;
84 property IgnoreKana: Boolean read FIgnoreKana write FIgnoreKana default false;
85 procedure Setroot(root :String);
86 function Getroot() : String;
88 function Getfullpath(argpath : String) : String;
89 procedure SetNGwordpath(path :String);
90 function GetNGwordpath() : String;
91 function LoadFromNGwordFile(path :String) : Boolean;
92 function ReLoadFromNGwordFile() : Boolean;
93 procedure LoadFromStringList( bufstl : TStringList );
94 function CheckAbonPopupRes(line : String; ThreadInfo: TAbonThread) :Boolean;
95 function FindNGwords(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean; ThreadInfo: TAbonThread) : Boolean;//1
\83\89\83C
\83\93\82¸
\82Â
\97p
\81B
96 //
\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)
97 procedure Execute(var ThreadStrings : TStringList; ThreadInfo: TAbonThread); overload;
98 procedure Execute(var ResString : String; ResNumber : Integer; ThreadInfo: TAbonThread); overload; //
\8eå
\82Éplugin
\82©
\82ç
\82ÌDat To HTML
\97p
100 {$IFDEF SPAM_FILTER_ENABLED}
101 //!
\83X
\83p
\83\80\83t
\83B
\83\8b\83^
\82Ì
\8aw
\8fK
102 procedure Learn( resList : TStringList );
104 //
\8cÂ
\95Ê
\82 \82Ú
\81`
\82ñ
\82µ
\82å
\82è
105 procedure IndividualAbon(var ThreadStrings : TStringList; SetResNumFile : String); overload;
106 procedure IndividualAbon(var ResString : String; SetResNumFile : String; ResNumber : Integer); overload;
107 procedure AddIndividualAbon( ResNum : Integer ; option : Integer; SetResNumFile : String);
108 function CheckIndividualAbonList(ResNum : Integer) : Boolean;
110 function EditNGwords(Owner: TForm): Boolean; //NGword.txt
\82ð
\8aJ
\82
\81B
111 function ShowAllTokens() : String; //
\83f
\83o
\83b
\83O
\97p
113 procedure GoHome();//List
\82Ì
\82P
\8ds
\96Ú
\82ð
\93Ç
\82Þ
114 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Þ
115 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Þ
117 function TreatSyria(AString: string): string;
119 function AddToken(AString: string; Invisible: Boolean): Boolean;
124 NGwordListFileName : String = 'NGwords.list';
128 uses MojuUtils, GikoSystem, GikoBayesian, Setting,
132 function InvidiAbonListSort( item1, item2 : Pointer ) : Integer;
135 Result := TIndiviAbon( item1 ).Res - TIndiviAbon( item2 ).Res;
139 destructor TIndiviAbonList.Destroy;
144 for i := 0 to Count - 1 do
145 if inherited Items[ i ] <> nil then
146 TObject( inherited Items[ i ] ).Free;
152 function TIndiviAbonList.GetItem( index : Integer ) : TIndiviAbon;
155 Result := TIndiviAbon( inherited Items[ index ] );
159 procedure TIndiviAbonList.SetItem( index : Integer; value : TIndiviAbon );
162 inherited Items[ index ] := Pointer( value );
166 procedure TIndiviAbonList.Sort;
169 inherited Sort( InvidiAbonListSort );
173 procedure TIndiviAbonList.LoadFromFile( const filePath : string );
175 bufStringList : TStringList;
181 if not FileExists( filePath ) then begin
186 FFilePath := filePath;
187 bufStringList := TStringList.Create;
189 bufStringList.LoadFromFile( filePath );
190 if bufStringList.Values[ 'Learned' ] <> '' then begin
191 FLearned := StrToInt( bufStringList.Values[ 'Learned' ] );
192 bufStringList.Delete( bufStringList.IndexOfName( 'Learned' ) );
198 for i := bufStringList.Count-1 downto 0 do begin
199 if bufStringList.Strings[i] = '' then begin
200 bufStringList.Delete(i);
205 for i := 0 to bufStringList.Count - 1 do begin
206 bufLine := Trim(bufStringList.Strings[i]);
207 item := TIndiviAbon.Create;
208 item.Res := StrToInt(Copy(bufLine,1,AnsiPos('-',bufLine)-1));
209 item.option := StrToInt(Copy(bufLine,AnsiPos('-',bufLine)+1,1));
218 procedure TIndiviAbonList.Save;
220 bufStringList : TStringList;
224 bufStringList := TStringList.Create;
226 bufStringList.Values[ 'Learned' ] := IntToStr( FLearned );
228 for i := 0 to Count - 1 do begin
230 IntToStr( Items[ i ].Res ) + '-' + IntToStr( Items[ i ].Option ) );
233 bufStringList.SaveToFile( FFilePath );
240 constructor TAbon.Create;
243 FAbonString := ' <> <> <> <><>';
244 FAbonRes := TIndiviAbonList.Create;
245 FpAbons := PChar(FAbonString);
246 FpAbone := FpAbons + Length(FAbonString);
250 destructor TAbon.Destroy;
255 //root
\82ÍExe\config\NGwords
\83t
\83H
\83\8b\83_
256 procedure TAbon.Setroot(root :String);
258 bufStringList : TStringList;
260 bufStringList := TStringList.Create;
262 if not DirectoryExists(root) then begin
265 if root[Length(root)] <> '\' then begin
268 Flistpath := root + NGwordListFileName;
269 LoadListFile(Flistpath, bufStringList);
275 function TAbon.Getroot() : String;
279 //NGwordpath
\82ÍNGword.txt
\82Ì
\83t
\83\8b\83p
\83X
280 procedure TAbon.SetNGwordpath(path :String);
282 FNGwordpath := Getfullpath(path);
283 LoadFromNGwordFile(FNGwordpath);
285 function TAbon.GetNGwordpath() : String;
287 Result := FNGwordpath;
289 //
\83t
\83\8b\83p
\83X
\82Å
\82È
\82¯
\82ê
\82Î
\83t
\83\8b\83p
\83X
\82É
\82µ
\82Ä
\95Ô
\82·
\81B
290 function TAbon.Getfullpath(argpath : String) : String;
292 if AnsiPos(':\',argpath) <> 2 then begin //
\83h
\83\89\83C
\83u
\82©
\82ç
\82Ì
\83t
\83\8b\83p
\83X
\82ª
\96³
\82¯
\82ê
\82Î
293 if Getroot() = '' then begin
294 Result := ''; //root
\83p
\83X
\82ª
\90Ý
\92è
\82³
\82ê
\82Ä
\82È
\82¢
\82©
\8bó
\82É
\82·
\82é
296 if (Froot[Length(Froot)] = '\') and (argpath[1] = '\') then begin //
\90æ
\93ª
\82Ì\
\82ð
\8dí
\8f\9c
299 Insert( Getroot(), argpath , 1);//root
\83p
\83X
\82ð
\91}
\93ü
307 //NGword
\83t
\83@
\83C
\83\8b\82Ì
\93Ç
\82Ý
\8d\9e\82Ý
308 function TAbon.LoadFromNGwordFile(path :String) : boolean;
310 bufstl : TStringList;
312 path := Getfullpath(path);
313 if path = '' then begin
317 bufstl := TStringList.Create;
319 if not FileExists(path) then begin
322 bufstl.SaveToFile(path);
326 bufstl.LoadFromFile(path);
327 LoadFromStringList( bufstl );
336 //NGword
\83\8a\83X
\83g
\93Ç
\82Ý
\8d\9e\82Ý
337 procedure TAbon.LoadFromStringList( bufstl : TStringList );
342 for i := bufstl.Count -1 downto 0 do begin
343 if bufstl.Strings[i] = '' then begin
347 SetLength(Ftokens,bufstl.Count);
348 for i := 0 to bufstl.Count -1 do begin
349 SetTokens(i , bufstl.Strings[i]);
356 //NGwordpath
\82ª
\8aù
\82É
\90Ý
\92è
\82³
\82ê
\82Ä
\82¢
\82é
\82Æ
\82«
\82Ì
\83\8a\83\8d\81[
\83h
\97p
\8aÖ
\90\94
357 function TAbon.ReLoadFromNGwordFile() : boolean;
359 if GetNGwordpath() ='' then begin
362 Result := LoadFromNGwordFile( GetNGwordpath() );
365 function TAbon.Getlistpath() : String;
369 procedure TAbon.Setlistpath(const Value : String);
371 Flistpath := Getfullpath(Value);
373 //
\88ê
\8ds
\82Ì
\92\86\82Ì
\83g
\81[
\83N
\83\93\82ð
\90Ø
\82è
\95ª
\82¯
\82Ä
\83Z
\83b
\83g
374 procedure TAbon.SetTokens(index: integer ; argline : String);
377 bufstl : TStringList;
384 bufstl := TStringList.Create;
387 if Length(argline) > 0 then begin
388 pos := AnsiPos(#9,argline);
389 while pos <> 0 DO begin
390 buftoken := Copy(argline,1,pos-1);
391 Delete(argline,1,pos);
392 if Length(buftoken) > 0 then begin
394 if (buftoken = DEF_REGEXP) then begin
396 //
\94Â
\81E
\83X
\83\8c\8ew
\92è
397 end else if ((AnsiPos(DEF_THREAD, buftoken) = 1) or
398 (AnsiPos(DEF_BOARD, buftoken) = 1)) and
399 (AnsiPos(DEF_END, buftoken) > 1) then begin
401 // >>
\82Å
\8en
\82Ü
\82é
\83g
\81[
\83N
\83\93\82Í
\83R
\83\81\83\93\83g
\88µ
\82¢
\82Å
\96³
\8e\8b\82·
\82é
402 end else if AnsiPos('>>', buftoken) <> 1 then begin
403 bufstl.Append(buftoken);
405 end else if ( bufstl.Count = 0 ) then begin
408 pos := AnsiPos(#9,argline);
410 if Length(argline) > 0 then begin
411 // >>
\82Å
\8en
\82Ü
\82é
\83g
\81[
\83N
\83\93\82Í
\83R
\83\81\83\93\83g
\88µ
\82¢
\82Å
\96³
\8e\8b\82·
\82é
412 if AnsiPos('>>', argline) <> 1 then begin
413 bufstl.Append(argline);
416 //
\8ae
\8eí
\8ew
\92è
\82Ì
\8f\87\88Ê
\81F
\93§
\96¾
\81¨
\94Â
\81E
\83X
\83\8c\81¨
\90³
\8bK
\95\
\8c»
417 if (RegExp = True) then begin
418 if (bufstl.Count > 0) and (bufstl.Strings[0] = '') then
419 bufstl.Insert(1, DEF_REGEXP) //
\93§
\96¾
\8ew
\92è
\82Ì
\8cã
\82É
\90³
\8bK
\95\
\8c»
\8ew
\92è
\82ð
\92u
\82
421 bufstl.Insert(0, DEF_REGEXP); //
\90³
\8bK
\95\
\8c»
\8ew
\92è
\82Í
\90æ
\93ª
\82É
\92u
\82
423 if (Target <> '') then begin
424 if (bufstl.Count > 0) and (bufstl.Strings[0] = '') then
425 bufstl.Insert(1, Target) //
\93§
\96¾
\8ew
\92è
\82Ì
\8cã
\82É
\94Â
\81E
\83X
\83\8c\8ew
\92è
\82ð
\92u
\82
427 bufstl.Insert(0, Target); //
\94Â
\81E
\83X
\83\8c\8ew
\92è
\82Í
\90æ
\93ª
\82É
\92u
\82
430 SetLength(Ftokens[index],ret);
431 for i := 0 to ret - 1 do begin
433 Ftokens[index][i] := ZenToHan(bufstl.Strings[i])
435 Ftokens[index][i] := bufstl.Strings[i];
443 //Debug
\97p
\82¿
\82á
\82ñ
\82ÆNG
\83\8f\81[
\83h
\82ð
\8fE
\82¦
\82Ä
\82¢
\82é
\82©
444 function TAbon.ShowAllTokens() : String;
450 for i := 0 to High(Ftokens) do begin
451 for j := 0 to High(Ftokens[i]) do begin
452 ret := ret + Ftokens[i][j];
460 //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
461 //
\82à
\82µ
\82à
\93§
\96¾
\82 \82Ú
\81`
\82ñ
\82É
\82·
\82é
\82È
\82çInbisible
\82ðtrue
\82É
\82µ
\82Ä
\95Ô
\82·
462 function TAbon.FindNGwords(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean; ThreadInfo: TAbonThread) : Boolean; //1
\83\89\83C
\83\93\82¸
\82Â
\97p
\81B
479 CheckTarget: Boolean;
482 if AnsiStrPosEx(PChar(line), PChar(line)+Length(line), FpAbons, FpAbone) = nil then begin
483 //
\91S
\94¼
\8ap
\82Ð
\82ç
\83J
\83i
\96³
\8e\8b\82·
\82é
\82©
485 target := ZenToHan(line)
489 trgLen := Length(target);
492 for lines := 0 to High(Ftokens) do begin
493 if Length(Ftokens[lines]) = 0 then begin
498 pts := PChar(bufline);
505 TokenCnt := Length(Ftokens[lines]);
506 for Chk := 0 to 2 do begin
507 if (Chk >= TokenCnt) then
509 if (Chk = 0) and (Ftokens[lines][0] = '') then begin
512 end else if ((AnsiPos(DEF_THREAD, Ftokens[lines][Chk]) = 1) or
513 (AnsiPos(DEF_BOARD, Ftokens[lines][Chk]) = 1))
514 and (AnsiPos(DEF_END, Ftokens[lines][Chk]) > 1) then begin
515 CheckTarget := ThreadInfo.IsTarget(Ftokens[lines][Chk]);
516 if (CheckTarget = False) then
518 Inc(start); //
\91Î
\8fÛ
\82Ì
\94Â
\81E
\83X
\83\8c
519 end else if (Ftokens[lines][Chk] = DEF_REGEXP) then begin
520 RegExp := True; //
\90³
\8bK
\95\
\8c»
526 if (CheckTarget = False) then begin //
\91Î
\8fÛ
\82Ì
\94Â
\81E
\83X
\83\8c\82Å
\82Í
\82È
\82¢
531 if (RegExp = True) and (AWKStr = nil) then begin
532 AWKStr := TAWKStr.Create(nil);
535 for cells := start to High(Ftokens[lines]) do begin
536 if (RegExp = False) then begin
537 pos := AnsiStrPosEx(pts, pte,
538 PChar(Ftokens[lines][cells]), PChar(Ftokens[lines][cells]) + Length(Ftokens[lines][cells]));
539 if pos = nil then begin
543 Delete(bufline, pos - pte + 1, Length(Ftokens[lines][cells]));
544 pts := PChar(bufline);
545 pte := pts + Length(bufline);
549 AWKStr.RegExp := Ftokens[lines][cells];
550 if (AWKStr.Match(AWKStr.ProcessEscSeq(target), RStart, RLength) < 1) then
551 hit := False; //
\83}
\83b
\83`
\82µ
\82È
\82¢
555 if (hit = False) then
556 Break; // 1
\82Â
\82Å
\82à
\83}
\83b
\83`
\82µ
\82È
\82¢
\8fê
\8d\87\82Í
\82 \82Ú
\81[
\82ñ
\82µ
\82È
\82¢
559 if hit = true then begin
560 NGwordsLineNum := lines + 1;
565 if (AWKStr <> nil) then
570 //
\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
571 procedure TAbon.Execute(var ThreadStrings : TStringList; ThreadInfo: TAbonThread);
574 NGwordsLine : Integer;
578 for i:=0 to ThreadStrings.Count - 1 do begin
580 if FindNGwords(ThreadStrings.Strings[i], NGwordsLine, invisi, ThreadInfo) <> Reverse then begin
581 if invisi = true then begin
582 ThreadStrings.Strings[i] := '';
584 if not ReturnNGwordLineNum and not SetNGResAnchor then begin
585 ThreadStrings.Strings[i] := FAbonString;
586 end else if not ReturnNGwordLineNum then begin
587 ThreadStrings.Strings[i] := Format(' <> <> <>>%d<><>',[(i+1)]);
588 end else if not SetNGResAnchor then begin
589 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]);
591 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)]);
595 bufline := ThreadStrings.Strings[i];
596 if Deleterlo = true then begin
597 bufline := CustomStringReplace(bufline,'&rlo;','');
598 bufline := CustomStringReplace(bufline,'&lro;','');
600 if Replaceul = true then begin
601 bufline := CustomStringReplace( bufline,'<ul>','<br>' );
602 bufline := CustomStringReplace( bufline,'</ul>','<br>' );
604 if DeleteSyria = true then
605 bufline := TreatSyria(bufline);
606 ThreadStrings.Strings[i] := bufline;
610 procedure TAbon.Execute(var ResString : String; ResNumber : Integer; ThreadInfo: TAbonThread);
612 NGwordsLine : Integer;
617 if FindNGwords(ResString, NGwordsLine, invisi, ThreadInfo) <> Reverse then begin
618 if invisi = true then begin
621 if not ReturnNGwordLineNum and not SetNGResAnchor then begin
622 ResString := FAbonString;
623 end else if not ReturnNGwordLineNum then begin
624 ResString := Format(' <> <> <>>%d<><>',[(ResNumber)]);
625 end else if not SetNGResAnchor then begin
626 ResString := Format(' <> <> <><B> %d
\8ds
\96Ú
\82ÌNG
\83\8f\81[
\83h
\82ª
\8aÜ
\82Ü
\82ê
\82Ä
\82¢
\82Ü
\82·
\81B</B><><>',[NGwordsLine]);
628 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)]);
632 bufline := ResString;
633 if Deleterlo = true then begin
634 bufline := CustomStringReplace( bufline,'&rlo;','' );
635 bufline := CustomStringReplace( bufline,'&lro;','' );
637 if Replaceul = true then begin
638 bufline := CustomStringReplace( bufline,'<ul>','<br>' );
639 bufline := CustomStringReplace( bufline,'</ul>','<br>' );
641 if DeleteSyria = true then
642 bufline := TreatSyria(bufline);
643 ResString := bufline;
649 //****************************************************************************//
650 //
\8c»
\8dÝ
\83Z
\83b
\83g
\82³
\82ê
\82Ä
\82¢
\82éNGword.txt
\82ð
\8aJ
\82
651 function TAbon.EditNGwords(Owner: TForm): Boolean;
658 if (GikoSys.Setting.NGTextEditor = False) then begin
659 Dlg := TNgEdit.Create(Owner);
661 Dlg.SetFilePath(FNGwordpath);
662 if (Dlg.ShowModal = mrOk) then begin
663 if (Dlg.GetReload = True) then
669 ShellExecute(0 ,nil,PChar(FNGwordpath),nil,nil,SW_SHOW);
674 //
\83|
\83b
\83v
\83A
\83b
\83v
\97p
\94»
\92è
\8aÖ
\90\94
675 function TAbon.CheckAbonPopupRes(line : String; ThreadInfo: TAbonThread) :Boolean;
680 if AbonPopupRes = true then begin
681 Result := FindNGwords(line, i, v, ThreadInfo);
686 //
\95¡
\90\94\82ÌNG
\83\8f\81[
\83h
\83e
\83L
\83X
\83g
\82ð
\93Ç
\82Ý
\8d\9e\82Þ==============================================
687 //List
\83t
\83@
\83C
\83\8b\82ð
\93Ç
\82Ý
\8d\9e\82Þ
688 function TAbon.LoadListFile(path :String; listStringList : TStringList) : Boolean;
691 listStringList.LoadFromFile(path);
694 listStringList.Append('
\88ê
\94Ê=NGword.txt');
695 listStringList.SaveToFile(path);
699 //List
\82Ì
\88ê
\82Â
\8e\9f\82ÌNG
\83\8f\81[
\83h
\83t
\83@
\83C
\83\8b\82ð
\93Ç
\82Ý
\8d\9e\82Þ
700 function TAbon.GoForward() : Boolean;
702 FNGwordFileIndex := FNGwordFileIndex + 1;
703 Result := ReadNGwordslist(FNGwordFileIndex);
705 //List
\82Ì
\88ê
\82Â
\91O
\82ÌNG
\83\8f\81[
\83h
\83t
\83@
\83C
\83\8b\82ð
\93Ç
\82Ý
\8d\9e\82Þ
706 function TAbon.GoBack() : Boolean;
708 FNGwordFileIndex := FNGwordFileIndex -1;
709 Result := ReadNGwordslist(FNGwordFileIndex);
711 //List
\82Ì
\82P
\8ds
\96Ú
\82ð
\93Ç
\82Þ
712 procedure TAbon.GoHome();
714 FNGwordFileIndex := 0;
715 ReadNGwordslist(FNGwordFileIndex);
717 //List
\82Ìline
\8ds
\96Ú
\82ð
\93Ç
\82Þ
718 function TAbon.ReadNGwordslist(line : Integer) : Boolean;
720 liststl : TStringList;
723 liststl := TStringList.Create;
725 if LoadListFile(Flistpath,liststl) = true then begin
726 if line < 0 then begin
727 line := liststl.Count - 1;
728 FNGwordFileIndex := liststl.Count - 1;
729 end else if line > liststl.Count - 1 then begin
731 FNGwordFileIndex := 0;
733 linebuf := liststl.Strings[line];
734 FNGwordname := Copy(linebuf,1,AnsiPos('=',linebuf)-1);
735 Delete(linebuf,1,AnsiPos('=',linebuf));
736 SetNGwordpath(linebuf);
747 {$IFDEF SPAM_FILTER_ENABLED}
748 procedure TAbon.Learn( resList : TStringList );
751 wordCount : TWordCount;
752 spamminess : Extended;
753 indiviAbon : TIndiviAbon;
755 SPAM_THRESHOLD = 0.9;
758 if GikoSys.Setting.SpamFilterAlgorithm = gsfaNone then Exit;
760 wordCount := TWordCount.Create;
762 if (FAbonRes.FLearned = 0) and (FAbonRes.Count = 0) then begin
763 //
\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«
764 //
\8cÂ
\95Ê
\82 \82Ú
\81`
\82ñ
\82ð
\8eg
\82Á
\82½
\8aw
\8fK
766 for i := 0 to FAbonRes.Count - 1 do begin
767 while (j < resList.Count) and (j + 1 < FAbonRes[ j ].Res) do begin
769 GikoSys.Bayesian.CountWord( resList[ j ], wordCount );
770 GikoSys.Bayesian.Learn( wordCount, False );
773 if j < resList.Count then begin
775 GikoSys.Bayesian.CountWord( resList[ j ], wordCount );
776 GikoSys.Bayesian.Learn( wordCount, True );
781 while j < resList.Count do begin
783 GikoSys.Bayesian.CountWord( resList[ j ], wordCount );
784 GikoSys.Bayesian.Learn( wordCount, False );
788 //
\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
789 //
\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é
790 for j := FAbonRes.FLearned to resList.Count - 1 do begin
792 spamminess := GikoSys.SpamParse( resList[ j ], wordCount );
793 if spamminess >= SPAM_THRESHOLD then begin
795 GikoSys.Bayesian.Learn( wordCount, True );
796 indiviAbon := TIndiviAbon.Create;
797 indiviAbon.Res := j + 1;
798 indiviAbon.Option := 1;
799 FAbonRes.Add( indiviAbon );
802 GikoSys.Bayesian.Learn( wordCount, False );
807 FAbonRes.FLearned := resList.Count;
814 GikoSys.Bayesian.Save;
819 //
\95¡
\90\94\82ÌNG
\83\8f\81[
\83h
\83e
\83L
\83X
\83g
\82ð
\93Ç
\82Ý
\8d\9e\82Þ=====
\82±
\82±
\82Ü
\82Å=================================
820 //
\8cÂ
\95Ê
\82 \82Ú
\81`
\82ñ
\8eÀ
\8ds
\8aÖ
\90\94
821 procedure TAbon.IndividualAbon(var ThreadStrings : TStringList; SetResNumFile : String);
826 f := LoadFromSetResNumFile( SetResNumFile );
827 FAbonRes.FFilePath := SetResNumFile; // Learn
\82Í
\82Å
\95Û
\91¶
\82·
\82é
\82Ì
\82Å
828 {$IFDEF SPAM_FILTER_ENABLED}
829 Learn( ThreadStrings );
833 for i := 0 to FAbonRes.Count - 1 do begin
834 if (FAbonRes[i].Res <= ThreadStrings.Count) and (FAbonRes[i].Res > 0) then begin
836 ThreadStrings.Strings[FAbonRes[i].Res-1] :=
837 '<font color="red">
\82 \82Ú
\81`
\82ñ
\8dÏ
\82Ý</font>' +
838 ThreadStrings.Strings[FAbonRes[i].Res-1];
840 if FAbonRes[i].option = 0 then begin
841 ThreadStrings.Strings[FAbonRes[i].Res-1] := '';
843 ThreadStrings.Strings[FAbonRes[i].Res-1] := '
\82 \82Ú
\81`
\82ñ<>
\82 \82Ú
\81`
\82ñ<>
\82 \82Ú
\81`
\82ñ<>
\82 \82Ú
\81`
\82ñ<>';
850 procedure TAbon.IndividualAbon(var ResString : String; SetResNumFile : String; ResNumber : Integer);
854 if FileExists(SetResNumFile) = true then begin
855 if LoadFromSetResNumFile(SetResNumFile) = true then begin
856 for i := 0 to FAbonRes.Count - 1 do begin
857 if FAbonRes[i].Res = ResNumber then begin
858 if FAbonRes[i].option = 0 then begin
861 ResString := '
\82 \82Ú
\81`
\82ñ<>
\82 \82Ú
\81`
\82ñ<>
\82 \82Ú
\81`
\82ñ<>
\82 \82Ú
\81`
\82ñ<>';
868 FIndividualFileName := SetResNumFile;
870 FAbonRes := TIndiviAbonList.Create;
874 //
\8cÂ
\95Ê
\82 \82Ú
\81`
\82ñ
\83t
\83@
\83C
\83\8b\93Ç
\82Ý
\8d\9e\82Ý
\8aÖ
\90\94
875 function TAbon.LoadFromSetResNumFile(SetResNumFile : String) : Boolean;
878 FIndividualFileName := SetResNumFile;
880 FAbonRes := TIndiviAbonList.Create;
881 if FileExists( SetResNumFile ) then begin
882 FAbonRes.LoadFromFile( SetResNumFile );
889 //
\8cÂ
\95Ê
\82 \82Ú
\81`
\82ñ
\83t
\83@
\83C
\83\8b\82É
\92Ç
\89Á
890 procedure TAbon.AddIndividualAbon( ResNum : Integer ; option : Integer; SetResNumFile : String);
892 IndividualFile : TStringList;
895 IndividualFile := TStringList.Create;
897 if FileExists(SetResNumFile) then begin
898 IndividualFile.LoadFromFile(SetResNumFile);
900 for j := 0 to IndividualFile.Count -1 do begin
901 if AnsiPos(IntToStr(ResNum) + '-', IndividualFile[j]) = 1 then begin
907 IndividualFile.Add(IntToStr(ResNum) + '-' + IntToStr(option))
909 IndividualFile[j] := IntToStr(ResNum) + '-' + IntToStr(option);
912 IndividualFile.Add(IntToStr(ResNum) + '-' + IntToStr(option));
914 IndividualFile.SaveToFile(SetResNumFile);
920 //
\83|
\83b
\83v
\83A
\83b
\83v
\82Ì
\94»
\92è
\97p
921 function TAbon.CheckIndividualAbonList(ResNum : Integer) : Boolean;
925 if (FAbonRes.Count > 0) and (FAbonRes[0].Res <> 0) then begin
926 for i := 0 to FAbonRes.Count - 1 do begin
927 if FAbonRes[i].Res = ResNum then begin
936 //
\83V
\83\8a\83A
\8cê
\83u
\83\89\83N
\83\89\91Î
\8dô
937 function TAbon.TreatSyria(AString: string): string;
941 //count: Integer; //(܀~ݏ)
943 p, pe, s, se : PChar;
951 pe := p + Length(AString);
953 se := s + Length(UNI_TAG);
955 p := AnsiStrPosEx(p, pe, s, se);
957 while p <> nil do begin
958 //&#
\82Ì
\8eè
\91O
\82Ü
\82Å
\83R
\83s
\81[
\82·
\82é
959 Result := Result + Copy(AString, 1, p - PChar(AString));
960 //&#
\82Ì
\8eè
\91O
\82Ü
\82Å
\8dí
\8f\9c\82·
\82é
961 Delete(AString, 1, p - PChar(AString));
963 //AString
\82É3
\95¶
\8e\9a\88È
\8fã
\82 \82ê
\82Î
\8e\9f\82Ì3
\95¶
\8e\9a\96Ú
\82ð
\83`
\83F
\83b
\83N
964 if Length(AString) > 2 then begin
965 ps := PChar(AString) + 2;
966 if (ps^ = 'x') or (ps^ = 'X') then begin
970 while ((ps^ >= '0') and (ps^ <= '9')) or
971 ((ps^ >= 'a') and (ps^ <= 'f')) or
972 ((ps^ >= 'A') and (ps^ <= 'F')) do begin
974 scode := scode + String(ps^);
980 while ((ps^ >= '0') and (ps^ <= '9')) do begin
981 scode := scode + String(ps^);
985 icode := StrToIntDef(scode, 0);
987 //
\8dÅ
\8cã
\82ª;
\82Å
\95Â
\82¶
\82Ä
\82¢
\82È
\82¯
\82ê
\82Î
\81A
\88ê
\95¶
\8e\9a\91O
\82Ü
\82Å
\82É
\82·
\82é
988 if not (ps^ = ';') then
991 //
\83V
\83\8a\83A
\8cê
\83u
\83\89\83N
\83\89\82Ì
\82Å
\82È
\82¢
992 if ( icode < 1758) or
993 ((icode > 1871) and (icode < 1958)) or
994 (icode > 1968) then begin
995 Result := Result + Copy(AString, 1, ps - PChar(AString) + 1);
998 Delete(AString, 1, ps - PChar(AString) + 1);
1000 //
\8cã
\82ë
\82É
\95¶
\8e\9a\82ª
\96³
\82¢
\82Ì
\82Å
\81A
\82»
\82Ì
\82Ü
\82ÜResult
\82É
\93Ë
\82Á
\8d\9e\82Þ
1001 Result := Result + AString;
1004 p := PChar(AString);
1005 pe := p + Length(AString);
1006 p := AnsiStrPosEx(p, pe, s, se);
1009 //
\8ec
\82Á
\82½
\95¶
\8e\9a\97ñ
\82ð
\91«
\82µ
\82Ä
\8c\8b\89Ê
\82É
\82·
\82é
1010 Result := Result + AString;
1013 // NG
\83\8f\81[
\83h
\83t
\83@
\83C
\83\8b\82É
\92Ç
\89Á
\92Ç
\89Á
\82³
\82ê
\82½
\8fê
\8d\87\81ATrue
\82ª
\82©
\82¦
\82é
1014 function TAbon.AddToken(AString: string; Invisible: Boolean): Boolean;
1016 bufStringList : TStringList;
1020 if FileExists(GetNGwordpath) then begin
1021 bufStringList := TStringList.Create;
1023 bufStringList.LoadFromFile(GetNGwordpath);
1024 if (Invisible) then begin
1025 ngword := #9 + AString;
1029 if (bufStringList.IndexOf(ngword) = -1) then begin
1030 bufStringList.Add(ngword);
1031 bufStringList.SaveToFile(GetNGwordpath);