public String explainScore ( StringWrapper s , StringWrapper t ) { StringBuffer buf = new StringBuffer ( ) ; BagOfTokens sBag = asBagOfTokens ( s ) ; BagOfTokens tBag = asBagOfTokens ( t ) ; double sumOverI = 0 ; for ( Iterator i = sBag . tokenIterator ( ) ; i . hasNext ( ) ; ) { Token tokenI = ( Token ) i . next ( ) ; buf . append ( "token=" + tokenI ) ; double maxOverJ = - Double . MAX_VALUE ; Token closestToI = null ; for ( Iterator j = tBag . tokenIterator ( ) ; j . hasNext ( ) ; ) { Token tokenJ = ( Token ) j . next ( ) ; double scoreItoJ = tokenDistance . score ( tokenI . getValue ( ) , tokenJ . getValue ( ) ) ; buf . append ( " dist(" + tokenJ . getValue ( ) + ")=" + scoreItoJ ) ; if ( scoreItoJ >= maxOverJ ) { maxOverJ = scoreItoJ ; closestToI = tokenJ ; } } sumOverI += maxOverJ ; buf . append ( " match=" + closestToI + " score=" + maxOverJ + "\n" ) ; } buf . append ( "total: " + sumOverI + "/" + sBag . size ( ) + " = " + score ( s , t ) + "\n" ) ; return buf . toString ( ) ; }
Explain how the distance was computed .