I am trying to calculate the tf-idf value for each term in a document. So, I repeat the terms in the document and I want to find the frequency of this term in the entire corpus and the number of documents in which this term appears. Below is my code:
Although the documentation states that totalTermFreq () returns the total number of occurrences of this term in all documents, when testing, I found that it returns the frequency of this term in the document specified by docNbr. and docFreq () always return 1.
How can I get member frequency throughout the index?
Update Of course, I can create a map to display the term on its frequency. Then iterate over each document to calculate the total amount of time that takes place. However, I thought Lucene should have a built-in method for this purpose. Thanks,
source share