src/ie/gmit/sw/ai/FileHandler.java
public HashMap<String, Integer> read4grams(String path) throws IOException {
		HashMap<String, Integer> map = new HashMap<String, Integer>();
	    String line;
	    BufferedReader reader = new BufferedReader(new FileReader(path));
	    while ((line = reader.readLine()) != null)
	    {
	    	String[] columns = line.split(" ");
	    	if (columns.length >= 2) {
	    		String key = columns[0];
	    		int freq = Integer.parseInt(columns[1]);
	    		map.put(key, freq);
	    	}//if
	    	else {
	    		System.out.println("ignoring line: " + line);
	    	}//else
	    }//while
	    reader.close();	
	    return map;
	}
//reads in the 4grams file into a hashmap
reads in the 4grams file into a hashmap
reads in the 4grams file into a hashmap
public HashMap<String, Integer> read4grams(String path) throws IOException {
		HashMap<String, Integer> map = new HashMap<String, Integer>();
	    String line;
	    BufferedReader reader = new BufferedReader(new FileReader(path));
	    while ((line = reader.readLine()) != null)
	    {
	    	String[] columns = line.split(" ");
	    	if (columns.length >= 2) {
	    		String key = columns[0];
	    		int freq = Integer.parseInt(columns[1]);
	    		map.put(key, freq);
	    	}
	    	else {
	    		System.out.println("ignoring line: " + line);
	    	}
	    }
	    reader.close();	
	    return map;
	}
public HashMap < String , Integer > read4grams ( String path ) throws IOException { HashMap < String , Integer > map = new HashMap < String , Integer > ( ) ; String line ; BufferedReader reader = new BufferedReader ( new FileReader ( path ) ) ; while ( ( line = reader . readLine ( ) ) != null ) { String [ ] columns = line . split ( " " ) ; if ( columns . length >= 2 ) { String key = columns [ 0 ] ; int freq = Integer . parseInt ( columns [ 1 ] ) ; map . put ( key , freq ) ; } else { System . out . println ( "ignoring line: " + line ) ; } } reader . close ( ) ; return map ; }
reads in the 4grams file into a hashmap
reads in the 4grams file into a hashmap
//if //else //while