English 中文(简体)
在从卢塞内指数获得文件顶端频率时,没有“披露错误”。
原标题:"no inclosing instance error " while getting top term frequencies for document from Lucene index

我正试图获得卢塞内指数中每个特定文件最经常出现的频率。 我试图确定我所关心的20个最容易出现的措辞。

然而,在请比较器时,我正在得到“无法公开显示器类型的例子”。

因此,我通过每份文件的载体,并尽我所知的最崇高术语。

protected static Collection getTopTerms(TermFreqVector tfv, int maxTerms){
  String[] terms = tfv.getTerms();   
  int[] tFreqs = tfv.getTermFrequencies();  

  List result = new ArrayList(terms.length); 

  for (int i = 0; i < tFreqs.length; i++) {
    TermFrq tf = new TermFrq(terms[i], tFreqs[i]);
    result.add(tf); 

  }
  Collections.sort(result, new FreqComparator()); 
  if(maxTerms < result.size()){
    result = result.subList(0, maxTerms);
  }
  return result; 
}
/*Class for objects to hold the term/freq pairs*/

static class TermFrq{
   private String term;
   private int freq;

   public TermFrq(String term,int freq){
   this.term = term;
   this.freq = freq;
 }
   public String getTerm(){
   return this.term;
 }
 public int getFreq(){
   return this.freq;
 }
}


/*Comparator to compare the objects by the frequency*/
 class FreqComparator implements Comparator{
  public int compare(Object pair1, Object pair2){
   int f1 = ((TermFrq)pair1).getFreq();
   int f2 = ((TermFrq)pair2).getFreq();

   if(f1 > f2) return 1;
   else if(f1 < f2) return -1;
   else return 0;
  }
}

解释和更正 我将非常赞赏,如果其他人在提炼频率方面有经验,并且做得更好,我将向所有建议开放!

请帮助! Thanx!

最佳回答

我认为,你需要制定你的术语表<代码>。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签