コード例 #1
0
 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);
   }
 }
コード例 #2
0
 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);
   }
 }
コード例 #3
0
  /* (non-Javadoc)
   * @see ac.biu.nlp.nlp.instruments.dictionary.wordnet.SensedWord#getRelatedSensedWords(ac.biu.nlp.nlp.instruments.dictionary.wordnet.WordNetRelation)
   */
  public Set<SensedWord> getNeighborSensedWords(WordNetRelation relation) throws WordNetException {

    Set<SensedWord> sensedWords = new LinkedHashSet<SensedWord>();
    if (relation.isLexical()) {
      List<Pointer> pointers =
          wordObj.getPointers(ExtJwnlUtils.wordNetRelationToPointerType(relation));
      for (Pointer pointer : pointers)
        // add a new SensedWord made of the Word-cast of this pointer
        sensedWords.add(new ExtJwnlSensedWord(((Word) pointer.getTarget()), dictionary));
    }
    return sensedWords;
  }
コード例 #4
0
 private static void cartPr(Set<Long> keys, List<Pointer> t) throws JWNLException {
   for (int i = 0; i < t.size(); i++) {
     Pointer ps = t.get(i);
     long sourceOffset = ps.getTargetSynset().getOffset();
     for (int j = i + 1; j < t.size(); j++) {
       Pointer pt = t.get(j);
       long targetOffset = pt.getTargetSynset().getOffset();
       if (sourceOffset != targetOffset) {
         long key;
         if (targetOffset > sourceOffset) {
           key = (targetOffset << 32) + sourceOffset;
         } else {
           key = (sourceOffset << 32) + targetOffset;
         }
         keys.add(key);
       }
     }
   }
 }