.pas yang pertama :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, jpeg, ExtCtrls, StdCtrls, Buttons, ComCtrls,xpman;
type
TForm1 = class(TForm)
Image1: TImage;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
BitBtn1: TBitBtn;
ProgressBar1: TProgressBar;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
begin
if edit1.Text = '' then
messagedlg('Anda belum memasukkan username atau password !', mtinformation, [mbok],0)
else
if edit2.Text = '' then
messagedlg('Anda belum memasukkan username atau password !', mtinformation, [mbok],0)
else
if edit2.Text = 'a' then
begin
form2.Show;
progressbar1.StepBy(100);
end
else
messagedlg('User name atau password yang anda masukkan salah !', mtinformation, [mbok],0);
end;
end;
end.
.pas yang kedua :
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus, ExtCtrls, jpeg;
type
TForm2 = class(TForm)
OpenDialog1: TOpenDialog;
Memo1: TMemo;
Button2: TButton;
Label1: TLabel;
MainMenu1: TMainMenu;
OpenFile1: TMenuItem;
OpenFile11: TMenuItem;
Label2: TLabel;
Memo2: TMemo;
Memo3: TMemo;
Label3: TLabel;
Label4: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
OpenFile21: TMenuItem;
OpenFile31: TMenuItem;
Image1: TImage;
Label5: TLabel;
Edit4: TEdit;
Memo4: TMemo;
OpenFile41: TMenuItem;
procedure Button2Click(Sender: TObject);
procedure OpenFile11Click(Sender: TObject);
procedure OpenFile21Click(Sender: TObject);
procedure OpenFile31Click(Sender: TObject);
procedure OpenFile41Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit3, Unit1;
{$R *.dfm}
procedure TForm2.Button2Click(Sender: TObject);
begin
form3.Show;
end;
procedure TForm2.OpenFile11Click(Sender: TObject);
var F: TextFile;
text1:string;
begin
if opendialog1.Execute then
begin
edit1.Text:=opendialog1.Files.GetText;
edit1.Text:=copy(edit1.Text,1,length(edit1.Text)-2);
if FileExists(edit1.Text) then
begin
memo1.Clear;
AssignFile(F, edit1.Text);
Reset(F);
while not eoln(f) do
begin
readln(F,text1);
memo1.Lines.add(text1);
end;
CloseFile(F);
end
else
ShowMessage('File '+edit1.Text+'tidak ditemukan');
end;
end;
procedure TForm2.OpenFile21Click(Sender: TObject);
var F: TextFile;
text1:string;
begin
if opendialog1.Execute then
begin
edit2.Text:=opendialog1.Files.GetText;
edit2.Text:=copy(edit2.Text,1,length(edit2.Text)-2);
if FileExists(edit2.Text) then
begin
memo2.Clear;
AssignFile(F, edit2.Text);
Reset(F);
while not eoln(f) do
begin
readln(F,text1);
memo2.Lines.add(text1);
end;
CloseFile(F);
end
else
ShowMessage('File '+edit2.Text+'tidak ditemukan');
end;
end;
procedure TForm2.OpenFile31Click(Sender: TObject);
var F: TextFile;
text1:string;
begin
if opendialog1.Execute then
begin
edit3.Text:=opendialog1.Files.GetText;
edit3.Text:=copy(edit3.Text,1,length(edit3.Text)-2);
if FileExists(edit3.Text) then
begin
memo3.Clear;
AssignFile(F, edit3.Text);
Reset(F);
while not eoln(f) do
begin
readln(F,text1);
memo3.Lines.add(text1);
end;
CloseFile(F);
end
else
ShowMessage('File '+edit3.Text+'tidak ditemukan');
end;
end;
procedure TForm2.OpenFile41Click(Sender: TObject);
var F: TextFile;
text1:string;
begin
if opendialog1.Execute then
begin
edit4.Text:=opendialog1.Files.GetText;
edit4.Text:=copy(edit4.Text,1,length(edit4.Text)-2);
if FileExists(edit4.Text) then
begin
memo4.Clear;
AssignFile(F, edit4.Text);
Reset(F);
while not eoln(f) do
begin
readln(F,text1);
memo4.Lines.add(text1);
end;
CloseFile(F);
end
else
ShowMessage('File '+edit4.Text+'tidak ditemukan');
end;
end;
end.
.pas yang ketiga :
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, Grids, jpeg, DB, DBGrids, DBCtrls, ExtCtrls;
type
TForm3 = class(TForm)
StringGrid1: TStringGrid;
StringGrid2: TStringGrid;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Image1: TImage;
Label7: TLabel;
Button2: TButton;
Label8: TLabel;
Label9: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses unit2, Unit1, Unit4;
var TnPeng: set of char=[' ', ',', '?', ';', '.', ':', '-','=', '+', '/', '*', '(', ')', '''', '>', '>', '`','"'];
dftUrut :TStringlist; {non-visual list to hold the words for sorting}
{$R *.dfm}
function pisahkata(var line:string):string;
var
i,start:integer;
begin
result:='';
if length(line)>0 then
begin
line:=line+' ';
start:=1;
while (line[start] in TnPeng) do inc(start);
i:=start+1;
if i<=length(line) then
while not (line[i] in TnPeng) do inc(i);
result:=copy(line,start,i-start);
delete(line,1,i);
end;
end;
function checkstopwords(kata:string):boolean;
var
i : integer;
line : string;
begin
result:=true;
for i:=0 to form2.memo1.lines.count-1 do
begin
line:=trim(form2.memo1.lines[i]);
if line<>'' then
begin
if kata=line then
begin
result:=false;
break;
end
else result:=true;
end;
end;
end;
procedure TForm3.Button1Click(Sender: TObject);
var
i, ii, count, count0,count1,count2,count3,count4 :integer;
line, kata, w, kata1, kata2,bd,bud : string;
txtloc : string; // posisi kata di dokumen (dari stringgrid)
txtpos,n: integer; // posisi kata di stringgrid , real position
nmrkata,m: integer; // posisi kata di stringlist , shorted position
textloc : array[0..500] of string[30];
textsum : array[1..500] of integer;
sgretrivrow, sgindexrow, akhir: integer;
katabaru: boolean;
f:textfile;
begin
// Retrieving.....
//for i:=0 to 500 do textloc[i]:='';
StringGrid1.Cols[0].Clear;
StringGrid1.Cols[1].Clear;
StringGrid1.Cols[2].Clear;
StringGrid2.Cols[0].Clear;
StringGrid2.Cols[1].Clear;
StringGrid2.Cols[2].Clear;
StringGrid2.Cols[3].Clear;
//listbox1.clear; //umpama pakai listbox
count0:=0;count1:=0;count2:=0;count3:=0;
StringGrid1.Cells[0,0]:='Nomor';
StringGrid1.Cells[1,0]:='Text';
StringGrid1.Cells[2,0]:='Tempat';
StringGrid2.Cells[0,0]:='Nomor';
StringGrid2.Cells[1,0]:='Text';
StringGrid2.Cells[2,0]:='Jumlah';
StringGrid2.Cells[3,0]:='Tempat';
//hitung jumlah kata di dokumen1
for i:=0 to form2.memo1.lines.count-1 do
begin
line:=form2.memo1.lines[i];
while line<>'' do
begin
w:=pisahkata(line);
if w<>'' then
begin
if checkstopwords(w) then
begin
inc(count0);inc(count1);
//listbox1.items.add(w); //umpama pakai listbox
StringGrid1.Cells[0,count0]:=IntToStr(count0);
StringGrid1.Cells[1,count0]:=w;
StringGrid1.Cells[2,count0]:='D1-'+IntToStr(count1);
end;
end;
end;
end;
//lbJmlKata1.caption:=inttostr(count1)+' Words in '+odDoc1.filename;
label1.caption:='Document 1 = '+inttostr(count1)+' Words.';
//hitung jumlah kata di dokumen2
for i:=0 to form2.memo2.lines.count-1 do
begin
line:=form2.memo2.lines[i];
while line<>'' do
begin
w:=pisahkata(line);
if w<>'' then
begin
if checkstopwords(w) then
begin
inc(count0);inc(count2);
//listbox1.items.add(w); //umpama pakai listbox
StringGrid1.Cells[0,count0]:=IntToStr(count0);
StringGrid1.Cells[1,count0]:=w;
StringGrid1.Cells[2,count0]:='D2-'+IntToStr(count2);
end;
end;
end;
end;
//lbJmlKata2.caption:=inttostr(count2)+' Words in '+odDoc2.filename;
label2.caption:='Document 2 = '+inttostr(count2)+' Words.';
//hitung jumlah kata di dokumen3
for i:=0 to form2.memo3.lines.count-1 do
begin
line:=form2.memo3.lines[i];
while line<>'' do
begin
w:=pisahkata(line);
if w<>'' then
begin
if checkstopwords(w) then
begin
inc(count0);inc(count3);
//listbox1.items.add(w); //seumpama pakai listbox
StringGrid1.Cells[0,count0]:=IntToStr(count0);
StringGrid1.Cells[1,count0]:=w;
StringGrid1.Cells[2,count0]:='D3-'+IntToStr(count3);
end;
end;
end;
end;
//label3.caption:=inttostr(count3)+' Words in '+odDoc3.filename;
label3.caption:='Document 3 = '+inttostr(count3)+' Words.';
// total jumlah kata di ke-3 dokumen
//hitung jumlah kata di dokumen4
for i:=0 to form2.memo4.lines.count-1 do
begin
line:=form2.memo4.lines[i];
while line<>'' do
begin
w:=pisahkata(line);
if w<>'' then
begin
if checkstopwords(w) then
begin
inc(count0);inc(count4);
//listbox1.items.add(w); //umpama pakai listbox
StringGrid1.Cells[0,count0]:=IntToStr(count0);
StringGrid1.Cells[1,count0]:=w;
StringGrid1.Cells[2,count0]:='D4-'+IntToStr(count4);
end;
end;
end;
end;
//lbJmlKata3.caption:=inttostr(count3)+' Words in '+odDoc3.filename;
label7.caption:='Document 4 = '+inttostr(count4)+' Words.';
//label4.caption:=inttostr(count1)+' Words in ALL documents.'
label4.caption:='Total = ';
label8.Caption:=inttostr(count0);
label9.caption:='Words.';
//sorting , summarizing , indexing ......
StringGrid2.Cells[0,1]:='1';
StringGrid2.Cells[1,1]:=StringGrid1.Cells[1,1];
StringGrid2.Cells[2,1]:='1'; //start sum
StringGrid2.Cells[3,1]:=StringGrid1.Cells[2,1];
textsum[1]:=1;
katabaru := false;
sgindexrow := 1;
sgretrivrow:=499;
for i:=2 to sgretrivrow do
begin
kata1:=StringGrid1.Cells[1,i];
akhir := sgindexrow;
if kata1<>'' then begin
for ii:=1 to akhir do
begin
kata2:=StringGrid2.Cells[1,ii];
if kata1=kata2 then
begin
textsum[ii]:=textsum[ii]+1;
StringGrid2.Cells[2,ii]:=IntToStr(textsum[ii]); //new sum
StringGrid2.Cells[3,ii]:=StringGrid2.Cells[3,ii]+', '+StringGrid1.Cells[2,i];
katabaru:=false;
akhir:=ii;
end
else katabaru:=true;
end;
if katabaru then
begin
//add new row
inc(sgindexrow);
ii:=sgindexrow;
StringGrid2.Cells[0,ii]:=IntToStr(ii);
StringGrid2.Cells[1,ii]:=StringGrid1.Cells[1,i];
StringGrid2.Cells[2,ii]:='1'; //new sum
StringGrid2.Cells[3,ii]:=StringGrid1.Cells[2,i];
textsum[ii]:=1;
katabaru:=false;
end;
end;
end;
begin
for n:=1 to stringgrid2.RowCount-1 do
begin
bd:=stringgrid2.Cells[1,n];
for m:=1 to stringgrid2.RowCount-1 do
begin
bud:=stringgrid2.Cells[1,m];
begin
if bd=bud then
stringgrid2.Cells[1,m]:='';
//melakukan inisialisasi untuk baris pertama
//melakukan perulangan untuk melakukan pencarian yang sama dengan dirinya
//lalu menghapusnya,tanpa yg pertama dihapus
end;
end;
end;
end;
end;
procedure TForm3.Button2Click(Sender: TObject);
begin
form4.show;
end;
end.
.pas yang keempat/akhir :
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, Buttons;
type
TForm4 = class(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
BitBtn1: TBitBtn;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
implementation
uses Unit3, Unit1;
{$R *.dfm}
procedure TForm4.FormCreate(Sender: TObject);
var i:integer;
begin
form4.StringGrid1.Cells[0,0]:='Nomor';
form4.StringGrid1.Cells[1,0]:='Text';
form4.StringGrid1.Cells[2,0]:='Peluang';
form4.StringGrid1.Cells[3,0]:='Kode';
form4.StringGrid1.Cells[4,0]:='Prosentase';
for i:=1 to 500 do
begin
form4.StringGrid1.cells[0,i]:=inttostr(i);
end;
end;
procedure TForm4.Button1Click(Sender: TObject);
var a,b,x,z,i,j:integer;
m:string;
n:real;
begin
begin
with form3.StringGrid2 do
for z:=1 to 500 do
begin
if cells[2,z]<>'' then
begin
x:=z;
end
else
break;
end;
end;
a:=1;
b:=0;
for i:=1 to 500 do
for j:=1 to x do
begin
form4.StringGrid1.Cells[1,i]:=form3.StringGrid2.Cells[1,i];
form4.StringGrid1.Cells[2,j]:=form3.StringGrid2.Cells[2,j] +'/'+ form3.Label8.Caption;
form4.StringGrid1.Cells[4,j]:=inttostr(((strtoint(form3.StringGrid2.Cells[2,j])*100) div strtoint(form3.Label8.Caption)))+' %';
form4.StringGrid1.Cells[3,1]:=inttostr(b);
end;
for j:=1 to x-1 do
begin
m:=m+inttostr(a);
form4.StringGrid1.Cells[3,j+1]:=m+inttostr(b);
form4.StringGrid1.Cells[3,x]:=m;
end;
end;
procedure TForm4.BitBtn1Click(Sender: TObject);
begin
form1.close;
end;
end.
ok sekian ingin lain2 hub email saya di broth3r_13@yahoo.com