I am writing a very basic java program that calculates frequency of each word in a sentence so far i managed to do this much
import java.io.*; class Linked
Determine the frequency of words in a file.
File f = new File(fileName); Scanner s = new Scanner(f); Map counts = new Map(); while( s.hasNext() ){ String word = s.next(); if( !counts.containsKey( word ) ) counts.put( word, 1 ); else counts.put( word, counts.get(word) + 1 );
}