【解压密码:QDAC】 type TWordMultiCutMode=(mcmShort,mcmDuality,mcmZMain,mcmZAll); TWordMultiCutModes=set of TWordMultiCutMode; PSCWSResultItem=^TSCWSResultItem; TSCWSResultItem=packed record Offset:Integer; Idf:single; Len:Byte; Attr:array[0..2] of AnsiChar; Next:PSCWSResultItem; end; PSCWSTopWordItem=^TSCWSTopWordItem; TSCWSTopWordItem=packed record Text:PAnsiChar;// Weight:single; Times:Smallint; Attr:array[0..1] of AnsiChar; Next:PSCWSTopWordItem; end;
TSCWSWordParser=class; TSCWSTopWords=class; TSCWSResult=class; TSCWSWordParser=class private FRuleFile: String; FHandle:THandle; FFlags:Integer; FCharset:String; function GetDuality: Boolean; function GetEnableIgnore: Boolean; procedure SetCharset(const Value: String); procedure SetDuality(const Value: Boolean); procedure SetEnableIgnore(const Value: Boolean); procedure SetRuleFile(const Value: String); function GetMultiCut: TWordMultiCutModes; procedure SetMultiCut(const Value: TWordMultiCutModes); protected constructor Create(AParent:TSCWSWordParser);overload; public constructor Create;overload; destructor Destroy;override; function Fork:TSCWSWordParser; function AddDict(AFileName:String;ALoadToMemory:Boolean):Boolean; function ReplaceDict(AFileName:String;ALoadToMemory:Boolean):Boolean; function Parse(S:String):TSCWSResult; function Tops(AMaxItem:Integer;AMask:String):TSCWSTopWords; property EnableIgnore:Boolean read GetEnableIgnore write SetEnableIgnore; property Charset:String read FCharset write SetCharset; property RuleFile:String read FRuleFile write SetRuleFile; property MultiModes:TWordMultiCutModes read GetMultiCut write SetMultiCut; property Duality:Boolean read GetDuality write SetDuality; end; TSCWSResult=class private function GetAttr: String; function GetBof: Boolean; function GetEof: Boolean; function GetIdf: Single; function GetLength: Integer; function GetOffset: Integer; function GetText: String; protected FHandle:THandle; FActive:PSCWSResultItem; FOwner:TSCWSWordParser; FSource:String; published public constructor Create(AOwner:TSCWSWordParser);overload; destructor Destroy;override; procedure First; function Next:Boolean; function NextWord:Boolean; property Text:String read GetText; property Offset:Integer read GetOffset; property Idf:Single read GetIdf; property Length:Integer read GetLength; property Attr:String read GetAttr; property Eof:Boolean read GetEof; property Bof:Boolean read GetBof; end;
TSCWSTopWords=class private function GetAttr: String; function GetBof: Boolean; function GetEof: Boolean; function GetText: String; function GetTimes: Integer; function GetWeight: Single; protected FHandle:THandle; FActive:PSCWSTopWordItem; FOwner:TSCWSWordParser; published public constructor Create(AOwner:TSCWSWordParser);overload; destructor Destroy;override; procedure First; function Next:Boolean; property Text:String read GetText; property Weight:Single read GetWeight; property Times:Integer read GetTimes; property Attr:String read GetAttr; property Eof:Boolean read GetEof; property Bof:Boolean read GetBof; end;