-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnalyseurOccurence.h
47 lines (40 loc) · 1.08 KB
/
AnalyseurOccurence.h
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
#ifndef ANALYSEUROCCURENCE_H_INCLUDED
#define ANALYSEUROCCURENCE_H_INCLUDED
#include "Analyseur.h"
class AnalyseurOccurence:public Analyseur{
public:
vector<Stat> analyser(vector<string> motsTraitees,string fichier);
};
bool existe(string mot, vector<Stat> tab){
for (Stat stat:tab){
if (stat.mot==mot){
return true;
}
}
return false;
}
vector<Stat> AnalyseurOccurence::analyser(vector<string> motsTraitees,string fichier){
vector<Stat> resultat;
for (string word:motsTraitees){
if(existe(word,resultat)){
int i=0;
while(true){
if (resultat.size()==0){break;}
if (resultat[i].mot == word){
resultat[i].stat+=1.0;
break;
}
i++;
}
}
else{
Stat motStat;
motStat.mot = word;
motStat.fichier = fichier;
motStat.stat = 1.0;
resultat.push_back(motStat);
}
}
return resultat;
}
#endif // ANALYSEUROCCURENCE_H_INCLUDED