public String explainScore(StringWrapper s, StringWrapper t) 
    {
        BagOfSourcedTokens sBag = (BagOfSourcedTokens)s;
        BagOfSourcedTokens tBag = (BagOfSourcedTokens)t;
        StringBuffer buf = new StringBuffer("");
        PrintfFormat fmt = new PrintfFormat("%.3f");
        buf.append("Common tokens: ");
        for (Iterator i = sBag.tokenIterator(); i.hasNext(); ) {
	    SourcedToken sTok = (SourcedToken)i.next();
            SourcedToken tTok = null;
            if ((tTok = tBag.getEquivalentToken(sTok))!=null) {
                buf.append(" "+sTok.getValue()+": ");
                buf.append(fmt.sprintf(sBag.getWeight(sTok)));
                buf.append("*"); 
                buf.append(fmt.sprintf(tBag.getWeight(tTok)));
            }
        }
        buf.append("\nscore = "+score(s,t));
        return buf.toString(); 
    }
public String explainScore ( StringWrapper s , StringWrapper t ) { BagOfSourcedTokens sBag = ( BagOfSourcedTokens ) s ; BagOfSourcedTokens tBag = ( BagOfSourcedTokens ) t ; StringBuffer buf = new StringBuffer ( "" ) ; PrintfFormat fmt = new PrintfFormat ( "%.3f" ) ; buf . append ( "Common tokens: " ) ; for ( Iterator i = sBag . tokenIterator ( ) ; i . hasNext ( ) ; ) { SourcedToken sTok = ( SourcedToken ) i . next ( ) ; SourcedToken tTok = null ; if ( ( tTok = tBag . getEquivalentToken ( sTok ) ) != null ) { buf . append ( " " + sTok . getValue ( ) + ": " ) ; buf . append ( fmt . sprintf ( sBag . getWeight ( sTok ) ) ) ; buf . append ( "*" ) ; buf . append ( fmt . sprintf ( tBag . getWeight ( tTok ) ) ) ; } } buf . append ( "\nscore = " + score ( s , t ) ) ; return buf . toString ( ) ; }
Explain how the distance was computed.
In the output, the tokens in S and T are listed, and the
common tokens are marked with an asterisk.