1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
| procedure TForm1.BitBtn2Click(Sender: TObject);
var i, p : integer;
mot : string;
car : char;
const FTemp = 'C:\windows\temp\dicoG.tmp';
begin
Cessez := false;
// initialisation des variables statistiques
NMots := 0;
NPhrases := 0;
NCarAlpha := 0;
For i := 0 to Flux.Size - 1 do
begin
Flux.Read (Car, 1);
case Car of
'a'..'z',
'A'..'Z',
'À'..'Ö', 'Ø'..'ö', 'ø'..'ÿ' :
begin
mot := mot + car;
inc (NCarAlpha);
end;
else
begin //détecter fin de phrases
if (pos (car, '.?!') > 0)
and (length (mot) > 1)
then inc (NPhrases);
if mot > '' then //fin de mot
begin
if Liste.Find (mot, p)
then Liste.incremente (p)
else Liste.AddObject(mot, TStat.Create) ;
inc (NMots);
mot := '';
end;
end;
end;
application.processmessages;
if Cessez then Break;
Panel1.Width := trunc (i * RichEdit1.width / Flux.size);
end;
Flux.Free;
// exclus
with Form2 do
if CheckExclus.Checked then
for i := 0 to Memo1.Lines.count - 1 do
if Liste.Find (Memo1.lines[i], p)
then Liste.Delete (p);
Liste.Sorted := False;
Case Form2.RadioGroup1.ItemIndex of
0 :; // alpha : ne rien faire ;
1 : // alpha + fréq : éditer
for i := 0 to Liste.count - 1
do Liste [i] := format (liste[i] + #9#9'%d', [liste.freq [i]]);
2 : // fréq : retrier
begin
Liste.TrieFreq (0, liste.count - 1);
for i := 0 to Liste.count - 1
do Liste [i] := format (liste[i] + #9#9'%d', [liste.freq [i]]);
end;
end;
Liste.Insert(0, #13#10'Résultats'#13#10);
// ajout des Stats à la liste;
with Form2 do
begin
if CheckMCarMot.Checked
then Liste.Insert (
0, Format ('Nombre moyen de caractères par mot : %.5f',
[NCarAlpha / NMots]));
if CheckNCarAlpha.Checked
then Liste.insert (
0, Format ('Nombre de caractères alphabétiques : %d',
[NCarAlpha]));
if CheckMotsPhrase.Checked
then Liste.insert (
0, Format ('Nombre moyen de mots par phrase : %.5f',
[NMots / NPhrases]));
if CheckNPhrases.Checked
then Liste.insert (
0, Format ('Nombre de Phrases : %d', [NPhrases]));
if CheckNMots.Checked
then Liste.insert (
0, format ('Nombre de mots : %d', [NMots]));
if (CheckNMots.Checked)
or (CheckNPhrases.Checked)
or (CheckMotsPhrase.Checked)
or (CheckNCarAlpha.Checked)
or (CheckMCarMot.Checked)
then Liste.insert (0, 'Statistiques'#13#10);
end; |
Partager