public static void viterbiTagger(String devDataFile, String countFile, String resultFile) throws IOException {

		FileReader in = new FileReader(devDataFile);
		BufferedReader br = new BufferedReader(in);

		// Store results from Viterbi tagging in a new file.
		File taggedResults = new File(resultFile);
		BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(
				taggedResults));

		String input;
		double maxProb = 0.0;
		String maxTag = "";
		String currentWord;
		ArrayList<String> sentenceArrayList = new ArrayList<String>();

		while ((input = br.readLine()) != null) {
			String sentence = "";
			sentenceArrayList = new ArrayList<String>();
			while (input.length() > 0) {
				sentence += input + " ";
				sentenceArrayList.add(input);
				input = br.readLine();
			}
			HashMap<Integer, HashMap<String, Double>> sentencePiTable = piTableGenerator(sentenceArrayList, countFile);
			for (int i = 0; i < sentenceArrayList.size(); i++) {
				maxProb = 0.0;
				maxTag = "";
				currentWord = sentenceArrayList.get(i);
				HashMap<String, Double> map = sentencePiTable.get((i + 1));
				for (String s : map.keySet()) {
					if (map.get(s).doubleValue() > maxProb) {
						maxProb = map.get(s).doubleValue();
						maxTag = s.substring(s.indexOf(' '));
					}
				}
				String write = currentWord + maxTag + " " + Math.log(maxProb)/Math.log(2) + "\n";
				bufferedWriter.write(write);
			}
			bufferedWriter.write("\n");
		}

		br.close();
		bufferedWriter.close();
	}