java progem to find distributional array of a word -


i want find frequency of word in each line of file. want every word in file. i'm using bufferedreader , filereader in java.

i recommend 2 things:

1) break down question better. trying find frequency of words in each line? or frequency of words in file. in, if input :

test test dog cat dog dog cat test cat dog dog cat test 

would want:

test: 2, 1 dog: 3, 2 cat: 2, 2 

or want

test: 3 dog: 5 cat: 4 

2) here's tools need

map<string,integer> wordcounts; // store word counts in class  /**  * countword- method signify counting word  * @param word word counted  */    public void countword(string word) {     int counts = 0; // assume not exist yet     if(wordcounts.containskey(word)) { // if does, count         counts = wordcounts.get(word);     } /* end if(contains(word))*/     wordcounts.put(word,counts + 1); // tell map put 1 more there } /* end countword */ 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -