procedure TForm1.SpeedButton4Click(Sender: TObject);
begin
Wortlistenanalyse(untwortliste,untfilelist);
end;
procedure CountOccurrences(
const MyList: TStrings;
var Result: TStrings);
var
i, CurIndex: Integer;
begin
for i := 0
to MyList.Count - 1
do
begin
CurIndex := Result.IndexOf(MyList[i]);
if CurIndex >= 0
then
Result.Objects[CurIndex] := TObject(Succ(Integer(Result.Objects[CurIndex])))
else
Result.AddObject(MyList[i], TObject(1));
end;
end;
Procedure Wortlistenanalyse (listenview:TListview; filelist: TFilelistbox);
var
untgesamt: integer;
refgesamt: integer;
listitem: tlistitem;
Textinhalt: Tstringlist;
Textinhaltallfiles: Tstringlist;
tokenlist: TStringlist;
templist: Tstrings;
i, ii:integer;
begin
if filelist.Items.Count=0
then exit;
listenview.Items.Clear;
Form1.speedbutton1.Enabled:=false;
Form1.Enabled:=false;
Form1.speedbutton4.Enabled:=false;
Form1.checkbox2.enabled:=false;
Textinhalt:= Tstringlist.Create;
Textinhaltallfiles:= Tstringlist.Create;
tokenlist:= tstringlist.create;
TempList := TStringList.Create;
Try
// Fileliste abarbeiten
for i:=0
to filelist.Items.Count -1
do begin //Alle Files einlesen
if fileexists(filelist.Items.Strings[i])
then textinhalt.LoadFromFile(filelist.Items.Strings[i])
else exit;
textinhaltallfiles.text := textinhaltallfiles.text + textinhalt.text;
end;
//Bei Checked: Alles Kleinbuchstaben
if Form1.checkbox2.Checked
then textinhaltallfiles.Text:=Ansilowercase(textinhaltallfiles.Text);
//Sonderzeichen raus
//textinhaltallfiles:= Reinigen(textinhaltallfiles);
//Geladenes File in Tokens zerlegen
untgesamt:= Extractstrings(['
'], [CHR(039)], pchar(textinhaltallfiles.text), tokenlist);
CountOccurrences(tokenlist, TempList);
for ii := 0
to TempList.Count - 1
do
with listenview
do begin
listitem := items.Add;
listitem.Caption := templist[ii];
listitem.SubItems.Add(inttostr(integer(templist.objects[ii])));
end;
Except
ShowMessage('
Exception class name = '+
Exception.ClassName);
end;
Textinhalt.Free;
TempList.Free;
Textinhaltallfiles.free;
tokenlist.free;
Form1.speedbutton1.Enabled:=true;
Form1.speedbutton2.Enabled:=true;
Form1.speedbutton4.Enabled:=true;
Form1.checkbox2.enabled:=true;
//if listenview=Object('untwortliste') then Form1.label5.caption:= 'Tokens ges.: ' + inttostr(untgesamt)
// else Form1.label6.caption:= 'Tokens ges.: ' + inttostr(untgesamt)
end;