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);
   }
 }
Example #2
0
 @Override
 public boolean retainAll(Collection<?> c) {
   if (null != dictionary && dictionary.isEditable()) {
     List<Pointer> copy = new ArrayList<Pointer>(this);
     boolean result = super.retainAll(c);
     for (Object object : c) {
       if (object instanceof Pointer) {
         Pointer pointer = (Pointer) object;
         if (!copy.contains(pointer)) {
           // delete symmetric pointer from the target
           if (null != pointer.getType().getSymmetricType()
               && dictionary.getManageSymmetricPointers()) {
             for (Pointer p : pointer.getTargetSynset().getPointers()) {
               if (offset == p.getTargetOffset()
                   && pointer.getType().getSymmetricType().equals(p.getType())) {
                 pointer.getTargetSynset().getPointers().remove(p);
                 break;
               }
             }
           }
         }
       }
     }
     return result;
   } else {
     return super.retainAll(c);
   }
 }
 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);
   }
 }
Example #4
0
 @Override
 public Pointer remove(int index) {
   Pointer result = super.remove(index);
   if (null != dictionary
       && dictionary.isEditable()
       && dictionary.getManageSymmetricPointers()) {
     // delete symmetric pointer from the target
     Pointer pointer = get(index);
     if (null != pointer.getType().getSymmetricType()) {
       for (Pointer p : pointer.getTargetSynset().getPointers()) {
         if (offset == p.getTargetOffset()
             && pointer.getType().getSymmetricType().equals(p.getType())) {
           pointer.getTargetSynset().getPointers().remove(p);
           break;
         }
       }
     }
   }
   return result;
 }
Example #5
0
 @Override
 protected void removeRange(int fromIndex, int toIndex) {
   if (null != dictionary && dictionary.isEditable()) {
     List<Pointer> copy = new ArrayList<Pointer>(super.subList(fromIndex, toIndex));
     super.removeRange(fromIndex, toIndex);
     for (Pointer pointer : copy) {
       // delete symmetric pointer from the target
       if (null != pointer.getType().getSymmetricType()
           && dictionary.getManageSymmetricPointers()) {
         for (Pointer p : pointer.getTargetSynset().getPointers()) {
           if (offset == p.getTargetOffset()
               && pointer.getType().getSymmetricType().equals(p.getType())) {
             pointer.getTargetSynset().getPointers().remove(p);
             break;
           }
         }
       }
     }
   } else {
     super.removeRange(fromIndex, toIndex);
   }
 }
Example #6
0
 @Override
 public void clear() {
   if (null != dictionary && dictionary.isEditable()) {
     List<Pointer> copy = new ArrayList<Pointer>(this);
     super.clear();
     for (Pointer pointer : copy) {
       // delete symmetric pointer from the target
       if (null != pointer.getType().getSymmetricType()
           && dictionary.getManageSymmetricPointers()) {
         for (Pointer p : pointer.getTargetSynset().getPointers()) {
           if (offset == p.getTargetOffset()
               && pointer.getType().getSymmetricType().equals(p.getType())) {
             pointer.getTargetSynset().getPointers().remove(p);
             break;
           }
         }
       }
     }
   } else {
     super.clear();
   }
 }
Example #7
0
 @Override
 public boolean remove(Object o) {
   boolean result = super.remove(o);
   if (null != dictionary
       && dictionary.isEditable()
       && dictionary.getManageSymmetricPointers()
       && o instanceof Pointer) {
     Pointer pointer = (Pointer) o;
     // delete symmetric pointer from the target
     if (null != pointer.getType().getSymmetricType()) {
       if (null != pointer.getTargetSynset()) {
         for (Pointer p : pointer.getTargetSynset().getPointers()) {
           if (offset == p.getTargetOffset()
               && pointer.getType().getSymmetricType().equals(p.getType())) {
             pointer.getTargetSynset().getPointers().remove(p);
             break;
           }
         }
       }
     }
   }
   return result;
 }