private char matchSuffix ( String str1 , String str2 ) { //here always str1.endsWith(str2) char rel = IMappingElement . IDK ; int spacePos1 = str1 . lastIndexOf ( ' ' ) ; String prefix = str1 . substring ( 0 , str1 . length ( ) - str2 . length ( ) ) ; if ( - 1 < spacePos1 && ! prefixes . containsKey ( prefix ) ) { //check prefixes - ordered set!unordered set if ( str1 . length ( ) == spacePos1 + str2 . length ( ) + 1 ) { //adhesive tape<tape attention deficit disorder<disorder rel = IMappingElement . LESS_GENERAL ; } else { //connective tissue<issue String left = str1 . substring ( spacePos1 + 1 , str1 . length ( ) ) ; char secondRel = match ( left , str2 ) ; if ( IMappingElement . MORE_GENERAL == secondRel || IMappingElement . EQUIVALENCE == secondRel ) { rel = IMappingElement . LESS_GENERAL ; } else { //?,<,! rel = secondRel ; } } } else { if ( prefix . startsWith ( "-" ) ) { prefix = prefix . substring ( 1 ) ; } if ( prefix . endsWith ( "-" ) && ! prefixes . containsKey ( prefix = prefix . substring ( 0 , prefix . length ( ) - 1 ) ) ) { //prefix = prefix.substring(0, prefix.length() - 1); //smth like cajun-creole, parrot-fish //but anti-virus rel = IMappingElement . LESS_GENERAL ; } else { if ( prefixes . containsKey ( prefix ) ) { rel = prefixes . get ( prefix ) ; } else if ( suffixes . containsKey ( str2 ) ) { rel = suffixes . get ( str2 ) ; } } //another approximation = Gversion4 // if (rel == MatchManager.LESS_GENERAL || rel == MatchManager.MORE_GENERAL) { // rel = MatchManager.EQUIVALENCE; // } } //filter = Gversion3 // if (MatchManager.LESS_GENERAL == rel || MatchManager.MORE_GENERAL == rel) { // rel = MatchManager.EQUIVALENCE; // } return rel ; }
Computes the relation with suffix matcher .