* Make sure term frequencies and
*/
public void phraseTfsCorrect()
{
// for each discovered phrase, do manual count and verify if tf and tfByDocument are correct.
AllPhrases allPhrases = context.allPhrases;
for (int index = 0; index < allPhrases.size(); index++)
{
IntIntOpenHashMap realTfByDocuments = countManually(context, allPhrases.wordIndices[index]);
final int realTf = realTfByDocuments.forEach(new IntIntProcedure()
{
int tf;
public void apply(int key, int value)
{
tf += value;
}
}).tf;
Assertions.assertThat(allPhrases.tf[index]).as("Phrase: " + allPhrases.getPhrase(index))
.isEqualTo(realTf);
// Phrase extractor does not sort the byDocumentTf, so we need to addAllFromFlattened
// to a map and then flatten with sorting.
Assertions
.assertThat(
IntMapUtils.flattenSortedByKey(IntMapUtils.addAllFromFlattened(
new IntIntOpenHashMap(), allPhrases.tfByDocument[index])))
.as("Phrase: " + allPhrases.getPhrase(index))
.isEqualTo(IntMapUtils.flattenSortedByKey(realTfByDocuments));
}
}