FileDocCategorySizeDatePackage
TermFreq.javaAPI DocExample2940Wed May 18 09:39:02 BST 2005com.discursive.jccook.xml.bardsearch

TermFreq

public class TermFreq extends Object

Fields Summary
private static Logger
logger
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] pArgs)

      LogInit.init(); 
        logger.info("Threshold is 200" );
        Integer threshold = new Integer( 200 );

        IndexReader reader = IndexReader.open( "index" );
        TermEnum enum = reader.terms();
        List termList = new ArrayList();
        while( enum.next() ) {
            if( enum.docFreq() >= threshold.intValue() && 
                enum.term().field().equals( "speech" ) ) {
                Freq freq = new Freq( enum.term().text(), enum.docFreq() );
                termList.add( freq );
            }
        }
        Collections.sort( termList );
        Collections.reverse( termList );

        System.out.println( "Frequency | Term" );
        Iterator iterator = termList.iterator();
        while( iterator.hasNext() ) {
            Freq freq = (Freq) iterator.next();
            System.out.print( freq.frequency );
            System.out.println( " | " + freq.term );
        }