| 39 |
|
|
| 40 |
TAbon = class(TObject) |
TAbon = class(TObject) |
| 41 |
private |
private |
| 42 |
{ Private 宣言 } |
{ Private 宣言 } |
| 43 |
Froot : String; |
Froot : String; |
| 44 |
Flistpath : String; |
Flistpath : String; |
| 45 |
FNGwordpath : String; |
FNGwordpath : String; |
| 46 |
Ftokens : array of array of string; |
Ftokens : array of array of string; |
| 47 |
FAbonRes : TIndiviAbonList; |
FAbonRes : TIndiviAbonList; |
| 48 |
FAbonString : String; |
FAbonString : String; |
| 49 |
|
FpAbons : PChar; |
| 50 |
|
FpAbone : PChar; |
| 51 |
FDeleterlo : Boolean; //&rlo;を削るか //追加&lro;も削る |
FDeleterlo : Boolean; //&rlo;を削るか //追加&lro;も削る |
| 52 |
FReplaceul :Boolean ; //<ul>タグを<br>タグに置換するか |
FReplaceul :Boolean ; //<ul>タグを<br>タグに置換するか |
| 53 |
FReverse : Boolean ; //NGワードでのあぼ〜んの結果を反転させるか |
FReverse : Boolean ; //NGワードでのあぼ〜んの結果を反転させるか |
| 54 |
FAbonPopupRes : Boolean; //レスポップアップの時にあぼーんするか |
FAbonPopupRes : Boolean; //レスポップアップの時にあぼーんするか |
| 55 |
FNGwordFileIndex : Integer; //現在読み込んでるNGワードがlistの何行目か |
FNGwordFileIndex : Integer; //現在読み込んでるNGワードがlistの何行目か |
| 56 |
FNGwordname : String; //現在読み込んでるNGワードの表示名 |
FNGwordname : String; //現在読み込んでるNGワードの表示名 |
| 57 |
FIndividualFileName : String; //個別あぼ〜んのファイル名 |
FIndividualFileName : String; //個別あぼ〜んのファイル名 |
| 58 |
FReturnNGwordLineNum : Boolean; //NGワードの行数を返す。 |
FReturnNGwordLineNum : Boolean; //NGワードの行数を返す。 |
| 59 |
FSetNGResAnchor : Boolean; //NGに該当したときに本文にそのレスへのレスアンカーをつけるかどうか |
FSetNGResAnchor : Boolean; //NGに該当したときに本文にそのレスへのレスアンカーをつけるかどうか |
| 60 |
FDeleteSyria: Boolean; //シリア語ブラクラ対策(܀~ݏ) |
FDeleteSyria: Boolean; //シリア語ブラクラ対策(܀~ݏ) |
| 61 |
procedure SetTokens(index: integer ; argline:String); |
FIgnoreKana: Boolean; //全角半角ひらがなカタカナの違いを無視するか |
| 62 |
function Getlistpath() : String; |
procedure SetTokens(index: integer ; argline:String); |
| 63 |
procedure Setlistpath(const Value : String); |
function Getlistpath() : String; |
| 64 |
function LoadListFile(path :String;listStringList : TStringList) : Boolean; |
procedure Setlistpath(const Value : String); |
| 65 |
function ReadNGwordslist(line : Integer) : Boolean; |
function LoadListFile(path :String;listStringList : TStringList) : Boolean; |
| 66 |
function LoadFromSetResNumFile(SetResNumFile : String) : Boolean; |
function ReadNGwordslist(line : Integer) : Boolean; |
| 67 |
|
function LoadFromSetResNumFile(SetResNumFile : String) : Boolean; |
| 68 |
public |
public |
| 69 |
{ Public 宣言 } |
{ Public 宣言 } |
| 70 |
constructor Create; // コンストラクタ |
constructor Create; // コンストラクタ |
| 71 |
destructor Destroy; override; // デストラクタ |
destructor Destroy; override; // デストラクタ |
| 72 |
property Deleterlo: Boolean read FDeleterlo write FDeleterlo default false; |
property Deleterlo: Boolean read FDeleterlo write FDeleterlo default false; |
| 73 |
property Replaceul: Boolean read FReplaceul write FReplaceul default false; |
property Replaceul: Boolean read FReplaceul write FReplaceul default false; |
| 74 |
property Reverse: Boolean read FReverse write FReverse default false; |
property Reverse: Boolean read FReverse write FReverse default false; |
| 75 |
property AbonString : String read FAbonString write FAbonString; |
property AbonString : String read FAbonString write FAbonString; |
| 76 |
property AbonPopupRes : Boolean read FAbonPopupRes write FAbonPopupRes default false; |
property AbonPopupRes : Boolean read FAbonPopupRes write FAbonPopupRes default false; |
| 77 |
property listpath : String read Getlistpath write Setlistpath; |
property listpath : String read Getlistpath write Setlistpath; |
| 78 |
property NGwordFileIndex : Integer read FNGwordFileIndex write FNGwordFileIndex default 0; |
property NGwordFileIndex : Integer read FNGwordFileIndex write FNGwordFileIndex default 0; |
| 79 |
property NGwordname : String read FNGwordname write FNGwordname; |
property NGwordname : String read FNGwordname write FNGwordname; |
| 80 |
property ReturnNGwordLineNum : Boolean read FReturnNGwordLineNum write FReturnNGwordLineNum default false; |
property ReturnNGwordLineNum : Boolean read FReturnNGwordLineNum write FReturnNGwordLineNum default false; |
| 81 |
property SetNGResAnchor : Boolean read FSetNGResAnchor write FSetNGResAnchor default false; |
property SetNGResAnchor : Boolean read FSetNGResAnchor write FSetNGResAnchor default false; |
| 82 |
property DeleteSyria : Boolean read FDeleteSyria write FDeleteSyria default false; |
property DeleteSyria : Boolean read FDeleteSyria write FDeleteSyria default false; |
| 83 |
procedure Setroot(root :String); |
property IgnoreKana: Boolean read FIgnoreKana write FIgnoreKana default false; |
| 84 |
function Getroot() : String; |
procedure Setroot(root :String); |
| 85 |
|
function Getroot() : String; |
| 86 |
function Getfullpath(argpath : String) : String; |
|
| 87 |
procedure SetNGwordpath(path :String); |
function Getfullpath(argpath : String) : String; |
| 88 |
function GetNGwordpath() : String; |
procedure SetNGwordpath(path :String); |
| 89 |
function LoadFromNGwordFile(path :String) : Boolean; |
function GetNGwordpath() : String; |
| 90 |
function ReLoadFromNGwordFile() : Boolean; |
function LoadFromNGwordFile(path :String) : Boolean; |
| 91 |
procedure LoadFromStringList( bufstl : TStringList ); |
function ReLoadFromNGwordFile() : Boolean; |
| 92 |
function CheckAbonPopupRes(line : String) :Boolean; |
procedure LoadFromStringList( bufstl : TStringList ); |
| 93 |
|
function CheckAbonPopupRes(line : String) :Boolean; |
| 94 |
function FindNGwords(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean;//1ラインずつ用。 |
function FindNGwords(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean;//1ラインずつ用。 |
| 95 |
//あぼ〜ん処理(NGワードでのフィルタリング) |
//あぼ〜ん処理(NGワードでのフィルタリング) |
| 96 |
procedure Execute(var ThreadStrings : TStringList); overload; |
procedure Execute(var ThreadStrings : TStringList); overload; |
| 114 |
function GoBack() : Boolean; //Listの一つ前のNGワードファイルを読み込む |
function GoBack() : Boolean; //Listの一つ前のNGワードファイルを読み込む |
| 115 |
//-- |
//-- |
| 116 |
function TreatSyria(AString: string): string; |
function TreatSyria(AString: string): string; |
| 117 |
|
//-- |
| 118 |
|
function AddToken(AString: string; Invisible: Boolean): Boolean; |
| 119 |
end; |
end; |
| 120 |
var |
var |
| 121 |
Abon1 :TAbon; |
Abon1 :TAbon; |
| 239 |
// 初期化 |
// 初期化 |
| 240 |
FAbonString := ' <> <> <> <><>'; |
FAbonString := ' <> <> <> <><>'; |
| 241 |
FAbonRes := TIndiviAbonList.Create; |
FAbonRes := TIndiviAbonList.Create; |
| 242 |
|
FpAbons := PChar(FAbonString); |
| 243 |
|
FpAbone := FpAbons + Length(FAbonString); |
| 244 |
|
|
| 245 |
end; |
end; |
| 246 |
|
|
| 376 |
pos : Integer; |
pos : Integer; |
| 377 |
buftoken : String; |
buftoken : String; |
| 378 |
begin |
begin |
|
pos := 0; |
|
| 379 |
bufstl := TStringList.Create; |
bufstl := TStringList.Create; |
| 380 |
try |
try |
| 381 |
if Length(argline) > 0 then begin |
if Length(argline) > 0 then begin |
| 384 |
buftoken := Copy(argline,1,pos-1); |
buftoken := Copy(argline,1,pos-1); |
| 385 |
Delete(argline,1,pos); |
Delete(argline,1,pos); |
| 386 |
if Length(buftoken) > 0 then begin |
if Length(buftoken) > 0 then begin |
| 387 |
bufstl.Append(buftoken); |
// >> で始まるトークンはコメント扱いで無視する |
| 388 |
|
if AnsiPos('>>', buftoken) <> 1 then begin |
| 389 |
|
bufstl.Append(buftoken); |
| 390 |
|
end; |
| 391 |
end else if ( bufstl.Count = 0 ) then begin |
end else if ( bufstl.Count = 0 ) then begin |
| 392 |
bufstl.Append(''); |
bufstl.Append(''); |
| 393 |
end; |
end; |
| 394 |
pos := AnsiPos(#9,argline); |
pos := AnsiPos(#9,argline); |
| 395 |
end; |
end; |
| 396 |
if Length(argline) > 0 then begin |
if Length(argline) > 0 then begin |
| 397 |
bufstl.Append(argline); |
// >> で始まるトークンはコメント扱いで無視する |
| 398 |
|
if AnsiPos('>>', argline) <> 1 then begin |
| 399 |
|
bufstl.Append(argline); |
| 400 |
|
end; |
| 401 |
end; |
end; |
| 402 |
ret := bufstl.Count; |
ret := bufstl.Count; |
| 403 |
SetLength(Ftokens[index],ret); |
SetLength(Ftokens[index],ret); |
| 404 |
for i := 0 to bufstl.Count - 1 do begin |
for i := 0 to bufstl.Count - 1 do begin |
| 405 |
Ftokens[index][i] := bufstl.Strings[i]; |
if IgnoreKana then |
| 406 |
|
Ftokens[index][i] := ZenToHan(bufstl.Strings[i]) |
| 407 |
|
else |
| 408 |
|
Ftokens[index][i] := bufstl.Strings[i]; |
| 409 |
end; |
end; |
| 410 |
end; |
end; |
| 411 |
finally |
finally |
| 439 |
hit : Boolean; |
hit : Boolean; |
| 440 |
bufline : String; |
bufline : String; |
| 441 |
start : Integer; |
start : Integer; |
| 442 |
|
target : String; |
| 443 |
|
pos : PChar; |
| 444 |
|
pts, pte : PChar; |
| 445 |
|
trgLen : Integer; |
| 446 |
begin |
begin |
| 447 |
hit := false; |
hit := false; |
| 448 |
if AnsiPos(FAbonString,line) <> 1 then begin |
if AnsiStrPosEx(PChar(line), PChar(line)+Length(line), FpAbons, FpAbone) = nil then begin |
| 449 |
|
//全半角ひらカナ無視するか |
| 450 |
|
if IgnoreKana then |
| 451 |
|
target := ZenToHan(line) |
| 452 |
|
else |
| 453 |
|
target := line; |
| 454 |
|
|
| 455 |
|
trgLen := Length(target); |
| 456 |
|
|
| 457 |
for lines := 0 to High(Ftokens) do begin |
for lines := 0 to High(Ftokens) do begin |
| 458 |
|
if Length(Ftokens[lines]) = 0 then begin |
| 459 |
|
Continue; |
| 460 |
|
end; |
| 461 |
hit := true; |
hit := true; |
| 462 |
bufline := line; |
bufline := target; |
| 463 |
|
pts := PChar(bufline); |
| 464 |
|
pte := pts + trgLen; |
| 465 |
|
|
| 466 |
if Ftokens[lines][0] <> '' then begin |
if Ftokens[lines][0] <> '' then begin |
| 467 |
Invisible := false; |
Invisible := false; |
| 468 |
start := 0; |
start := 0; |
| 472 |
end; |
end; |
| 473 |
|
|
| 474 |
for cells := start to High(Ftokens[lines]) do begin |
for cells := start to High(Ftokens[lines]) do begin |
| 475 |
if AnsiPos(Ftokens[lines][cells],bufline) = 0 then begin |
pos := AnsiStrPosEx(pts, pte, |
| 476 |
|
PChar(Ftokens[lines][cells]), PChar(Ftokens[lines][cells]) + Length(Ftokens[lines][cells])); |
| 477 |
|
if pos = nil then begin |
| 478 |
hit := false; |
hit := false; |
| 479 |
break; |
break; |
| 480 |
end else begin |
end else begin |
| 481 |
Delete(bufline,AnsiPos(Ftokens[lines][cells],bufline),Length(Ftokens[lines][cells])); |
Delete(bufline, pos - pte + 1, Length(Ftokens[lines][cells])); |
| 482 |
|
pts := PChar(bufline); |
| 483 |
|
pte := pts + Length(bufline); |
| 484 |
end; |
end; |
| 485 |
end; |
end; |
| 486 |
if hit = true then begin |
if hit = true then begin |
| 894 |
Dec(ps); |
Dec(ps); |
| 895 |
|
|
| 896 |
//シリア語ブラクラのでない |
//シリア語ブラクラのでない |
| 897 |
if (icode <1792) or (icode > 1871) then |
if ( icode < 1758) or |
| 898 |
Result := Result + Copy(AString, 1, ps - PChar(AString) + 1); |
((icode > 1871) and (icode < 1958)) or |
| 899 |
|
(icode > 1968) then begin |
| 900 |
|
Result := Result + Copy(AString, 1, ps - PChar(AString) + 1); |
| 901 |
|
end; |
| 902 |
|
|
| 903 |
Delete(AString, 1, ps - PChar(AString) + 1); |
Delete(AString, 1, ps - PChar(AString) + 1); |
| 904 |
end else begin |
end else begin |
| 915 |
Result := Result + AString; |
Result := Result + AString; |
| 916 |
end; |
end; |
| 917 |
|
|
| 918 |
|
// NGワードファイルに追加 追加された場合、Trueがかえる |
| 919 |
|
function TAbon.AddToken(AString: string; Invisible: Boolean): Boolean; |
| 920 |
|
var |
| 921 |
|
bufStringList : TStringList; |
| 922 |
|
ngword: String; |
| 923 |
|
begin |
| 924 |
|
Result := False; |
| 925 |
|
if FileExists(GetNGwordpath) then begin |
| 926 |
|
bufStringList := TStringList.Create; |
| 927 |
|
try |
| 928 |
|
bufStringList.LoadFromFile(GetNGwordpath); |
| 929 |
|
if (Invisible) then begin |
| 930 |
|
ngword := #9 + AString; |
| 931 |
|
end else begin |
| 932 |
|
ngword := AString; |
| 933 |
|
end; |
| 934 |
|
if (bufStringList.IndexOf(ngword) = -1) then begin |
| 935 |
|
bufStringList.Add(ngword); |
| 936 |
|
bufStringList.SaveToFile(GetNGwordpath); |
| 937 |
|
Result := True; |
| 938 |
|
end; |
| 939 |
|
finally |
| 940 |
|
bufStringList.Free; |
| 941 |
|
end; |
| 942 |
|
end; |
| 943 |
|
end; |
| 944 |
|
|
| 945 |
|
|
| 946 |
end. |
end. |