Example #1
0
 public static int getWNSense(Annotation np1, Annotation np2, Document doc) throws JWNLException {
   Synset[] synset1 = Synsets.getValue(np1, doc);
   Synset[] synset2 = Synsets.getValue(np2, doc);
   if (synset1 == null || synset2 == null || synset1.length == 0 || synset2.length == 0)
     return NumericFeature.WN_SENSE_MAX;
   return getWNSense(synset1, synset2);
 }
Example #2
0
 public static boolean isSubclass(Annotation np1, Annotation np2, Document doc) {
   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;
   return isSubclass(synset1, synset2);
 }
Example #3
0
  /*
   * Returns the WordNet graph traversal distance of a relationship between two
   * words.
   */
  public static int wnDist(Annotation np1, Annotation np2, Document doc) throws JWNLException {
    // if(!getNPSemType(np1, annotations, text).equals(NPSemTypeEnum.UNKNOWN)&&getNPSemType(np1,
    // annotations,
    // text).equals(getNPSemType(np2, annotations, text)))
    // return 0;
    Synset[] synset1 = Synsets.getValue(np1, doc);
    Synset[] synset2 = Synsets.getValue(np2, doc);

    if (synset1 == null || synset2 == null || synset1.length == 0 || synset2.length == 0)
      return NumericFeature.WN_MAX;

    return getDistance(synset1[0], synset2[0], NumericFeature.WN_MAX);
  }
Example #4
0
  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;
  }