1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| var Mots : TStringList;
...
Question:=LowerCase(Question);
for i:=0 to Length(Question) do
begin
if Question[i] in ['.',';',',','?',':','!','(',')',''''] then Question[i]:=' ';
if Question[i] in ['é','è'] then Question[i]:='e';
if Question[i] in ['à','â'] then Question[i]:='a';
if Question[i] in ['ç'] then Question[i]:='c';
if Question[i] in ['ô'] then Question[i]:='o';
end;
//Ici, on a supprimé les majuscules, tous les accents, et la ponctuation
Mots:=TStringList.Create;
Mots.Delimiter:=' ';
Mots.DelimitedText:=Question;
//Ici, la phrase est dans un tableau. Pour tester si la phrase contient un mot, il suffit de faire : Mots.IndexOf('bonjour') qui renvoie une valeur différente de -1 si le mot est présente dans la phrase.
Mots.Free; |
Partager