public char match ( String str1 , String str2 ) { if ( null == str1 || null == str2 || 0 == str1 . length ( ) || 0 == str2 . length ( ) ) { return IMappingElement . IDK ; } String [ ] grams1 = generateNGrams ( str1 , gramlength ) ; String [ ] grams2 = generateNGrams ( str2 , gramlength ) ; int count = 0 ; for ( String aGrams1 : grams1 ) for ( String aGrams2 : grams2 ) { if ( aGrams1 . equals ( aGrams2 ) ) { count ++ ; break ; } } float sim = ( float ) 2 * count / ( grams1 . length + grams2 . length ) ; // Dice-Coefficient if ( threshold <= sim ) { return IMappingElement . EQUIVALENCE ; } else { return IMappingElement . IDK ; } }
Computes the relation with NGram matcher .