@@ -0,0 +1,1938 @@
+package markpeng.kaggle;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.FileReader;%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0Aimport org.apache.hadoop.conf.Configuration;%0Aimport org.apache.hadoop.fs.Path;%0Aimport org.apache.mahout.classifier.naivebayes.BayesUtils;%0A%0Apublic class PredictResultReader %7B%0A%09public static Map%3CString, Integer%3E readCategoryByTweetIds(%0A%09%09%09Configuration configuration, String tweetFileName) throws Exception %7B%0A%09%09Map%3CString, Integer%3E categoryByTweetIds = new HashMap%3CString, Integer%3E();%0A%09%09BufferedReader reader = new BufferedReader(%0A%09%09%09%09new FileReader(tweetFileName));%0A%09%09while (true) %7B%0A%09%09%09String line = reader.readLine();%0A%09%09%09if (line == null) %7B%0A%09%09%09%09break;%0A%09%09%09%7D%0A%09%09%09String%5B%5D tokens = line.split(%22%5Ct%22, 2);%0A%09%09%09String tweetId = tokens%5B0%5D;%0A%09%09%09Integer categoryId = Integer.parseInt(tokens%5B1%5D);%0A%09%09%09categoryByTweetIds.put(tweetId, categoryId);%0A%09%09%7D%0A%09%09reader.close();%0A%09%09return categoryByTweetIds;%0A%09%7D%0A%0A%09public static void main(String%5B%5D args) throws Exception %7B%0A%09%09if (args.length %3C 3) %7B%0A%09%09%09System.out%0A%09%09%09%09%09.println(%22Arguments: %5Btweet file%5D %5Blabel index%5D %5Bclass labels%5D%22);%0A%09%09%09return;%0A%09%09%7D%0A%09%09String tweetFileName = args%5B0%5D;%0A%09%09String labelIndexPath = args%5B1%5D;%0A%09%09String tweetCategoryIdsPath = args%5B2%5D;%0A%09%09Configuration configuration = new Configuration();%0A%09%09Map%3CString, Integer%3E categoryByTweetIds = readCategoryByTweetIds(%0A%09%09%09%09configuration, tweetCategoryIdsPath);%0A%09%09Map%3CInteger, String%3E labels = BayesUtils.readLabelIndex(configuration,%0A%09%09%09%09new Path(labelIndexPath));%0A%09%09BufferedReader reader = new BufferedReader(%0A%09%09%09%09new FileReader(tweetFileName));%0A%09%09while (true) %7B%0A%09%09%09String line = reader.readLine();%0A%09%09%09if (line == null) %7B%0A%09%09%09%09break;%0A%09%09%09%7D%0A%09%09%09String%5B%5D tokens = line.split(%22%5Ct%22, 2);%0A%09%09%09String tweetId = tokens%5B0%5D;%0A%09%09%09String tweet = tokens%5B1%5D;%0A%09%09%09int categoryId = categoryByTweetIds.get(tweetId);%0A%09%09%09System.out.println(tweetId + %22: %22 + tweet);%0A%09%09%09System.out.println(%22 =%3E %22 + labels.get(categoryId));%0A%09%09%7D%0A%09%09reader.close();%0A%09%7D%0A%7D%0A

Add PredictResultReader.