我想将读取lucene索引的结果存储到jTable中,以便我可以通过不同的列对其进行排序.从索引我正在阅读具有不同频率度量的术语.
表列是这些:
[string term] [int absFrequency] [int docFrequency] [double invFrequency]
所以我在AbstractTableModel中我可以定义列名,但我不知道如何使用以下方法得到Object [] []数据:
public static void FrequencyMap(Directory indexDir) throws Exception
{
ListredoviLista = new ArrayList();
//final Map map = new TreeMap();
ListtermList = new ArrayList();
IndexReader iReader = IndexReader.open(indexDir);
FilterIndexReader fReader = new FilterIndexReader(iReader);
int numOfDocs = fReader.numDocs();
TermEnum terms = fReader.terms();
while (terms.next()){
Term term = terms.term();
String termText = term.text();
termList.add(termText);
//Calculating the frequencies
int df = iReader.docFreq(term);
double idf = 0.0F;
idf = Math.log10((double) numOfDocs / df);
double tfidf = (df*idf);
//Here comes important part
//Changes according to takoi's answer
ArrayList oneRow = new ArrayList();
oneRow.add(termText);
oneRow.add(df);
oneRow.add(idf);
oneRow.add(tfidf);
redoviLista.add(oneRow);
}
iReader.close();
// So I need something like this,and i Neeed this array to be stored out of this method
所以我很友好地坚持在这里继续实现AbstractTableModel并填充并显示这个表….:/
请帮忙!