public void init() { FileInputStream propertiesStream; try { propertiesStream = new FileInputStream(CONFIG_PATH + FILE_CONFIG_NAME); JWNL.initialize(propertiesStream); // tagger = new StandfordTagger(); // tagger.init(); wordnet = Dictionary.getInstance(); relationFinder = RelationshipFinder.getInstance(); } catch (JWNLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (FileNotFoundException ef) { // TODO Auto-generated catch block ef.printStackTrace(); } }
public static boolean ancestorWN(Annotation np1, Annotation np2, Document doc) throws JWNLException { /* // Startup Wordnet if (wordnet == null) { try { JWNL.initialize(new FileInputStream(propsFile)); wordnet = Dictionary.getInstance(); } catch (Exception ex) { throw new RuntimeException(ex); } } IndexWord w1; IndexWord w2; // This searches the wordnet database w/o any morph processing done // to the word. w1 = wordnet.getIndexWord(POS.NOUN, word1); w2 = wordnet.getIndexWord(POS.NOUN, word2); // To have WN do morph processing... // IndexWord w1 = wordnet.lookupIndexWord(POS.NOUN, word1); // IndexWord w2 = wordnet.lookupIndexWord(POS.NOUN, word2); */ Synset[] synset1 = Synsets.getValue(np1, doc); Synset[] synset2 = Synsets.getValue(np2, doc); if (synset1 == null || synset2 == null || synset1.length == 0 || synset2.length == 0) return false; // Check for relationships amongst all senses. for (Synset element : synset1) { for (Synset element2 : synset2) { RelationshipList hypo = RelationshipFinder.getInstance() .findRelationships(element, element2, PointerType.HYPONYM); if (!hypo.isEmpty()) return true; } } return false; }