This a program which presents how many times does each word occur within a text file. what is going on is that its also picking up characters like ? and , i only want it to pick letters. This is just part of the results {"1"=1, "Cheers"=1, "Fanny"=1, "I=1, "biscuits"=1, "chairz")=1, "cheeahz"=1, "crisps"=1, "jumpers"=1, ?=20, work:=1
import java.io.File;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.TreeMap;
import java.util.StringTokenizer;
public class Unigrammodel {
public static void main(String [] args){
    //Creating BufferedReader to accept the file name from the user
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String fileName = null;
    System.out.print("Please enter the file name with path: ");
    try{
        fileName = (String) br.readLine();
        //Creating the BufferedReader to read the file
        File textFile = new File(fileName);
        BufferedReader input = new BufferedReader(new FileReader(textFile));
        //Creating the Map to store the words and their occurrences
        TreeMap<String, Integer> frequencyMap = new TreeMap<String, Integer>();
        String currentLine = null;
        //Reading line by line from the text file
        while((currentLine = input.readLine()) != null){
            //Parsing the words from each line
            StringTokenizer parser = new StringTokenizer(currentLine); 
            while(parser.hasMoreTokens()){
                String currentWord = parser.nextToken();
                //remove all non-alphanumeric from this word
            currentWord.replaceAll(("[^A-Za-z0-9 ]"), "");
                Integer frequency = frequencyMap.get(currentWord); 
                if(frequency == null){
                    frequency = 0;                      
                }
                //Putting each word and its occurrence into Map 
                frequencyMap.put(currentWord, frequency + 1);
            }
        }
        //Displaying the Result
        System.out.println(frequencyMap +"\n");
    }catch(IOException ie){
        ie.printStackTrace();
        System.err.println("Your entered path is wrong");
    }       
}
}
 
    