public String toTableString ( boolean probs ) { Set < B > key2s = Sets . newHashSet ( ) ; for ( A key : counts . keySet ( ) ) { key2s . addAll ( counts . get ( key ) . keySet ( ) ) ; } List < B > key2List = Lists . newArrayList ( key2s ) ; StringBuilder sb = new StringBuilder ( ) ; sb . append ( "\t" ) ; for ( B key2 : key2List ) { sb . append ( key2 ) ; sb . append ( "\t" ) ; } sb . append ( "\n" ) ; for ( A key1 : counts . keySet ( ) ) { sb . append ( key1 ) ; sb . append ( "\t" ) ; for ( B key2 : key2List ) { if ( probs ) { sb . append ( String . format ( "%.3f" , getProbability ( key1 , key2 ) ) ) ; } else { sb . append ( getCount ( key1 , key2 ) ) ; } sb . append ( "\t" ) ; } sb . append ( "\n" ) ; } return sb . toString ( ) ; }
Generates a 2D table displaying the contents of this accumulator .