private static Set<Long> findNounHypernyms(Dictionary dic) throws SMatchException {
   log.info("Creating noun hypernyms array...");
   try {
     Set<Long> keys = new HashSet<>();
     int count = 0;
     Iterator<Synset> it = dic.getSynsetIterator(POS.NOUN);
     while (it.hasNext()) {
       count++;
       if (0 == count % 10000) {
         log.debug("noun hypernyms: " + count);
       }
       Synset source = it.next();
       long sourceOffset = source.getOffset();
       traverseTreeMG(keys, PointerUtils.getHypernymTree(source), sourceOffset);
       traverseTreeMG(keys, PointerUtils.getInheritedHolonyms(source), sourceOffset);
       traverseTreeMG(keys, PointerUtils.getInheritedMemberHolonyms(source), sourceOffset);
       traverseTreeMG(keys, PointerUtils.getInheritedPartHolonyms(source), sourceOffset);
       traverseTreeMG(keys, PointerUtils.getInheritedSubstanceHolonyms(source), sourceOffset);
       traverseListMG(keys, PointerUtils.getHolonyms(source), sourceOffset);
       traverseListMG(keys, PointerUtils.getMemberHolonyms(source), sourceOffset);
       traverseListMG(keys, PointerUtils.getPartHolonyms(source), sourceOffset);
       traverseListMG(keys, PointerUtils.getSubstanceHolonyms(source), sourceOffset);
     }
     log.info("Noun hypernyms: " + keys.size());
     return keys;
   } catch (JWNLException e) {
     throw new SMatchException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
   }
 }
 private static Set<Long> findAdverbAntonyms(Dictionary dic) throws SMatchException {
   log.info("Creating adverb antonyms array...");
   try {
     Set<Long> keys = new HashSet<>();
     int count = 0;
     Iterator<Synset> it = dic.getSynsetIterator(POS.ADVERB);
     while (it.hasNext()) {
       count++;
       if (0 == count % 1000) {
         log.debug("adverb antonyms: " + count);
       }
       Synset source = it.next();
       long sourceOffset = source.getOffset();
       List<Pointer> pointers = source.getPointers(PointerType.ANTONYM);
       for (Pointer ptr : pointers) {
         long targetOffset = ptr.getTargetOffset();
         long key;
         if (targetOffset > sourceOffset) {
           key = (targetOffset << 32) + sourceOffset;
         } else {
           key = (sourceOffset << 32) + targetOffset;
         }
         keys.add(key);
       }
     }
     log.info("Adverbs antonyms: " + keys.size());
     return keys;
   } catch (JWNLException e) {
     throw new SMatchException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
   }
 }
 private static Set<Long> findNominalizations(Dictionary dic) throws SMatchException {
   log.info("Creating nominalizations array...");
   try {
     Set<Long> keys = new HashSet<>();
     int count = 0;
     Iterator<Synset> it = dic.getSynsetIterator(POS.VERB);
     while (it.hasNext()) {
       count++;
       if (0 == count % 1000) {
         log.debug("nominalizations: " + count);
       }
       Synset source = it.next();
       List<Pointer> pointers = source.getPointers(PointerType.DERIVATION);
       for (Pointer pointer : pointers) {
         if (POS.NOUN.equals(pointer.getTargetPOS())) {
           long targetOffset = pointer.getTargetOffset();
           long key = (source.getOffset() << 32) + targetOffset;
           keys.add(key);
         }
       }
     }
     log.info("Nominalizations: " + keys.size());
     return keys;
   } catch (JWNLException e) {
     throw new SMatchException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
   }
 }
Exemple #4
0
 private void removeFromIndexWords(Word word) {
   if (null != dictionary && dictionary.isEditable()) {
     try {
       // take care of IndexWords
       IndexWord indexWord = dictionary.getIndexWord(getPOS(), word.getLemma());
       if (null != indexWord) {
         indexWord.getSenses().remove(Synset.this);
       }
     } catch (JWNLException e) {
       if (log.isErrorEnabled()) {
         log.error(JWNL.resolveMessage("EXCEPTION_001", e.getMessage()), e);
       }
     }
   }
 }
Exemple #5
0
 private void addToIndexWords(Word word) {
   if (null != dictionary && dictionary.isEditable()) {
     try {
       // take care of IndexWords
       IndexWord iw = dictionary.getIndexWord(word.getPOS(), word.getLemma());
       if (null == iw) {
         dictionary.createIndexWord(word.getPOS(), word.getLemma(), Synset.this);
       } else {
         iw.getSenses().add(Synset.this);
       }
     } catch (JWNLException e) {
       if (log.isErrorEnabled()) {
         if (log.isErrorEnabled()) {
           log.error(JWNL.resolveMessage("EXCEPTION_001", e.getMessage()), e);
         }
       }
     }
   }
 }
 private static Set<Long> findAdjectiveAntonyms(Dictionary dic) throws SMatchException {
   log.info("Creating adjective antonyms array...");
   try {
     Set<Long> keys = new HashSet<>();
     int count = 0;
     Iterator<Synset> it = dic.getSynsetIterator(POS.ADJECTIVE);
     while (it.hasNext()) {
       count++;
       if (0 == count % 1000) {
         log.debug("adjective antonyms: " + count);
       }
       Synset current = it.next();
       traverseTree(keys, PointerUtils.getExtendedAntonyms(current), current.getOffset());
       traverseListSym(keys, PointerUtils.getAntonyms(current), current.getOffset());
     }
     log.info("Adjective antonyms: " + keys.size());
     return keys;
   } catch (JWNLException e) {
     throw new SMatchException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
   }
 }
  private static Set<Long> findNounAntonyms(Dictionary dic) throws SMatchException {
    log.info("Creating noun antonyms array...");
    try {
      Set<Long> keys = new HashSet<>();
      int count = 0;
      Iterator<Synset> it = dic.getSynsetIterator(POS.NOUN);
      while (it.hasNext()) {
        count++;
        if (0 == count % 10000) {
          log.debug("noun antonyms: " + count);
        }
        Synset source = it.next();

        cartPr(keys, source.getPointers(PointerType.PART_MERONYM));
        cartPr(keys, source.getPointers(PointerType.SUBSTANCE_MERONYM));
        cartPr(keys, source.getPointers(PointerType.MEMBER_MERONYM));
      }

      log.info("Noun antonyms: " + keys.size());
      return keys;
    } catch (JWNLException e) {
      throw new SMatchException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
    }
  }