package test;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import jules.Categorizer;
import jules.QueryPassager;
import jules.RankNouns;
import jules.Reranker;
import jules.ScoreWord;

import org.junit.Before;
import org.junit.Test;

import tagging.PosTagger;
import tagging.Word;
import util.Constants;
import util.Pair;

public class RankNounsTest {

	Map<String, String> questions;
	PrintWriter writer;
	int queries = 100;

	@SuppressWarnings("resource")
	@Before
	public void setUp() throws Exception {
		questions = new HashMap<String, String>();
		File dir = new File(Constants.qDir);
		writer = new PrintWriter("test.txt", "UTF-8");
		for (File f : dir.listFiles()) {
			if(f.getName().startsWith(".")) continue;
			System.out.println("Reading file: " + f.getName());
			BufferedReader br = new BufferedReader(new FileReader(f));
			String line;
			while ((line = br.readLine()) != null) {
				String[] cols = line.split("\t");
				if (!cols[6].trim().contains(" "))
					questions.put(cols[5].trim().toLowerCase(), cols[6].trim()
							.toLowerCase());
			}
		}
	}

	@Test
	public void test() {
		//writer.println(Integer.toString(questions.entrySet().size()));
		for (Entry<String, String> question : questions.entrySet()) {
			//System.out.println(question.getKey());
			List<Map<String, String>> res = QueryPassager.query(
					question.getKey(), queries);

			List<ScoreWord> lm = RankNouns.findTopNouns(res);
			
			int i = 0;
			//System.out.println(lm.get(0).getTotalRank());
			for (ScoreWord sw : lm) {
				String s = sw.lemma;
				i++;
				if (s.equalsIgnoreCase(question.getValue())){
					//			  index found 		rank				total number of nouns
					writer.println(i + "\t" + sw.getTotalRank() + "\t" + lm.size());
					writer.flush();
					break;
				}
			}
		}
		writer.close();
	}
}

@@ -397,16 +397,40 @@
 eWord;%0A%0A
+import minerva.Minerva;%0A
 import o
@@ -1346,242 +1346,113 @@
 %7B%0A%09%09
-//writer.println(Integer.toString(questions.entrySet().size()));%0A%09%09for (Entry%3CString, String%3E question : questions.entrySet()) %7B%0A%09%09%09//System.out.println(question.getKey());%0A%09%09%09List%3CMap%3CString, String%3E%3E res = QueryPassager.query(%0A%09%09%09%09%09
+for (Entry%3CString, String%3E question : questions.entrySet()) %7B%0A%09%09%09int i = 0;%0A%09%09%09Minerva min = new Minerva(
 ques
@@ -1480,17 +1480,16 @@
 s);%0A
-%0A
 %09%09%09
-List%3C
+for (
 Scor
@@ -1497,138 +1497,31 @@
 Word
-%3E lm = RankNouns.findTopNouns(res);%0A%09%09%09%0A%09%09%09int i = 0;%0A%09%09%09//System.out.println(lm.get(0).getTotalRank());%0A%09%09%09for (ScoreWord sw : lm
+ sw : min.getTopNouns()
 ) %7B%0A
@@ -1722,10 +1722,25 @@
 %22 + 
-l
 m
+in.getTopNouns()
 .siz

Use the Minerva API ® in RankNounsTest †††