String[] wordForms = A_prime[i].getWordForms();
for (int j = 0; j < wordForms.length; j++)
{
if (wordForms[j].compareTo(A) != 0) {
//Search corpus... A':B
Float score = new Float(countPhraseFrequencies(INDEX_DIR, wordForms[j], B));
phrase_frequencies.put(score,new Pair<String>(wordForms[j],B));
count++;
}
if(count >= NUM_SIM)
break;
}
if(count >= NUM_SIM)
break;
}
count = 0;
for (int i = 0; (i < NUM_SIM && i < B_prime.length); i++) {
String[] wordForms = B_prime[i].getWordForms();
for (int j = 0; j < wordForms.length; j++)
{
if (wordForms[j].compareTo(B) != 0) {
//Search corpus... A:B'
Float score = new Float(countPhraseFrequencies(INDEX_DIR,A, wordForms[j]));
phrase_frequencies.put(score,new Pair<String>(A,wordForms[j]));
count++;
}
if(count >= NUM_SIM)
break;
}
if(count >= NUM_SIM)
break;
}
// filter out the phrases and add the top 3 to the ArrayList, and return it
Iterator iter = phrase_frequencies.keySet().iterator();
//TODO: make number of filters dynamic
//create Array with size = num filters
ArrayList<String> filtered_phrases = new ArrayList<String>();
Float filter1 = new Float(0.0);
Float filter2 = new Float(0.0);
Float filter3 = new Float(0.0);
while (iter.hasNext()) {
Float curr_key = (Float)iter.next();
//this will bump the filters up each time a greater value comes along
//so that filter1 will be the greatest key and filter3 the 3rd greatest
if (curr_key > filter1) {
filter3 = filter2;
filter2 = filter1;