001/** 002 * 003 */ 004package org.dllearner.algorithms.isle.index; 005 006/** 007 * Compare the word types of two given words. 008 * @author Lorenz Buehmann 009 * 010 */ 011public class WordTypeComparator { 012 013 /** 014 * Returns TRUE if both POS tags are related to the same word type, i.e. whether both are NOUNS, VERBS, etc. , 015 * else FALSE is returned. 016 * @param posTag1 the POS tag of the first word 017 * @param posTag2 the POS tag of the second word 018 * @return 019 */ 020 public static boolean sameWordType(String posTag1, String posTag2){ 021 if(posTag1.startsWith("NN") && posTag2.startsWith("NN") || //nouns 022 posTag1.startsWith("V") && posTag2.startsWith("V") || //verbs 023 posTag1.startsWith("JJ") && posTag2.startsWith("JJ") || //adjectives 024 posTag1.startsWith("RB") && posTag2.startsWith("RB")) //adverbs 025 { 026 return true; 027 } else { 028 return posTag1.equals(posTag2); 029 } 030 } 031 032 public static int hashCode(String posTag){ 033 if(posTag.startsWith("NN")){//nouns 034 return "NN".hashCode(); 035 } else if(posTag.startsWith("V")){//verbs 036 return "V".hashCode(); 037 } else if(posTag.startsWith("JJ")){//adjectives 038 return "JJ".hashCode(); 039 } else if(posTag.startsWith("RB")){//adverbs 040 return "RB".hashCode(); 041 } else { 042 return posTag.hashCode(); 043 } 044 } 045}