Methods Summary |
---|
public java.lang.String | getField()
return null;
|
public int[] | getTermFrequencies()
return termFreqs;
|
public java.lang.String[] | getTerms()
return terms;
|
public int | indexOf(java.lang.String term)
int res = Arrays.binarySearch(terms, term);
return res >= 0 ? res : -1;
|
public int[] | indexesOf(java.lang.String[] terms, int start, int len)
int res[] = new int[len];
for (int i=0; i < len; i++) {
res[i] = indexOf(terms[i]);
}
return res;
|
private void | processTerms(java.lang.String[] queryTerms)
if (queryTerms != null) {
Arrays.sort(queryTerms);
Map tmpSet = new HashMap(queryTerms.length);
//filter out duplicates
List tmpList = new ArrayList(queryTerms.length);
List tmpFreqs = new ArrayList(queryTerms.length);
int j = 0;
for (int i = 0; i < queryTerms.length; i++) {
String term = queryTerms[i];
Integer position = (Integer)tmpSet.get(term);
if (position == null) {
tmpSet.put(term, new Integer(j++));
tmpList.add(term);
tmpFreqs.add(new Integer(1));
}
else {
Integer integer = (Integer)tmpFreqs.get(position.intValue());
tmpFreqs.set(position.intValue(), new Integer(integer.intValue() + 1));
}
}
terms = (String[])tmpList.toArray(terms);
//termFreqs = (int[])tmpFreqs.toArray(termFreqs);
termFreqs = new int[tmpFreqs.size()];
int i = 0;
for (Iterator iter = tmpFreqs.iterator(); iter.hasNext();) {
Integer integer = (Integer) iter.next();
termFreqs[i++] = integer.intValue();
}
}
|
public int | size()
return terms.length;
|
public final java.lang.String | toString()
StringBuffer sb = new StringBuffer();
sb.append('{");
for (int i=0; i<terms.length; i++) {
if (i>0) sb.append(", ");
sb.append(terms[i]).append('/").append(termFreqs[i]);
}
sb.append('}");
return sb.toString();
|