|
发表于 2013-11-12 16:29:43
|
显示全部楼层
本帖最后由 damcool 于 2013-11-12 16:30 编辑
- program StringMatching;
- {$mode objfpc}{$H+}
- uses
- {$IFDEF UNIX}{$IFDEF UseCThreads}
- cthreads,
- {$ENDIF}{$ENDIF}
- Classes,Sysutils
- { you can add units after this };
- var
- Dictionary,Data :TStringList;
- Results :TStringList;
- i,j,m,n :integer;
- begin
- Dictionary:=TStringList.Create;
- Dictionary.LoadFromFile('utf8_keywords.txt');
- Data:=TStringList.Create;
- Data.LoadFromFile('utf8_data.txt');
- Results:= TStringList.Create;
- writeln('Start Time:'+TimeToStr(Now));
- m:=Data.Count div 10;
- n:=Data.Count div 100;
- for i:=0 to Data.Count-1 do
- begin
- j:=0;
- if (i mod m =0) then
- write('>')
- else if (i mod n =0) then write('.');
- while j<Dictionary.Count do
- begin
- if pos(Dictionary.Strings[j],Data.Strings[i])>0 then
- begin
- Results.Add(Dictionary.Strings[j]);
- Dictionary.Delete(j);
- end
- else inc(j);
- end;
- end;
- writeln;
- writeln('Completed Time:'+TimeToStr(Now));
- Results.SaveToFile('utf8_results.txt');
- Results.Free;
- Data.Free;
- Dictionary.Free;
- end.
复制代码 |
|