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
|
static String[] dictionnaire={"de","des","dans","le","la","les","et","aux","à"};
public static void main(String[] args) throws IOException {
String mot ;
String ligneIN=null;
StringTokenizer st;
HashSet<String> interdits=new HashSet<String>();
for (int i = 0; i < dictionnaire.length; i++) {
interdits.add(dictionnaire[i]);
}
HashMap<String,Frequence> tabMotsDiff=new HashMap<String,Frequence>();
BufferedReader fin=new BufferedReader(new FileReader("/home/nono/Bureau/test.txt"));
while((ligneIN=fin.readLine())!=null) {
st=new StringTokenizer(ligneIN," ?,.;:!\"");
while(st.hasMoreTokens()) {
mot=st.nextToken();
if(!interdits.contains(mot)) {
if(tabMotsDiff.containsKey(mot)) {tabMotsDiff.get(mot).increment();}
else {tabMotsDiff.put(mot, new Frequence());}
}
}
fin.close();
System.out.println(tabMotsDiff);
} |
Partager