public void printBigrams ( PrintWriter output , SignificanceTest test , int minOccurrencePerToken ) { String [ ] indexToToken = new String [ tokenCounts . size ( ) ] ; for ( Map . Entry < String , TokenStats > e : tokenCounts . entrySet ( ) ) indexToToken [ . getValue ( ) . index ] = . getKey ( ) . toString ( ) ; LOGGER . info ( "Number of bigrams: " + bigramCounts . size ( ) ) ; for ( Map . Entry < Long , Number > e : bigramCounts . entrySet ( ) ) { long bigram = e . getKey ( ) . longValue ( ) ; int firstTokenIndex = ( int ) ( bigram >>> 32 ) ; int secondTokenIndex = ( int ) ( bigram & 0xFFFFFFFF L ) ; int bigramCount = e . getValue ( ) . intValue ( ) ; // Skip processing any bigram whose tokens occur less than the // minimum required TokenStats t1 = tokenCounts . get ( indexToToken [ firstTokenIndex ] ) ; TokenStats t2 = tokenCounts . get ( indexToToken [ secondTokenIndex ] ) ; //System.err.printf("t1: %s, t2: %s%n", t1, t2); if ( t1 . count < minOccurrencePerToken || t2 . count < minOccurrencePerToken ) continue ; int [ ] contingencyTable = getContingencyTable ( t1 , t2 , bigramCount ) ; double score = getScore ( contingencyTable , test ) ; output . println ( score + " " + indexToToken [ firstTokenIndex ] + " " + indexToToken [ secondTokenIndex ] ) ; } }
Prints all of the known bigrams where each token in the bigram must occur at least the number of specified time .