/** * Returns whether <var>that</var> is symmetric to this pointer. * @param that pointer * @return true, if <var>that</var> is symmetric to this pointer. * @throws JWNLException JWNLException */ public boolean isSymmetricTo(Pointer that) throws JWNLException { return null != pointerType.getSymmetricType() && that.getType().equals(pointerType.getSymmetricType()) && that.getTarget().equals(getSource()) && that.getSource().equals(getTarget()); }
private void addSymmetricPointerToTarget(Pointer original) { if (null != original.getType().getSymmetricType()) { try { boolean found = false; for (Pointer p : original.getTargetSynset().getPointers()) { if (p.isSymmetricTo(original)) { found = true; break; } } if (!found) { Pointer symmetric = new Pointer(original.getType().getSymmetricType(), original.getTarget(), original.getSource()); original.getTargetSynset().getPointers().add(symmetric); } } catch (JWNLException e) { throw new JWNLRuntimeException(e); } } }
public String toString() { String targetMsg = (target == null) ? targetIndex.toString() : target.toString(); return ResourceBundleSet.insertParams("[PointerTarget: [Source Index: {0}] Source: {1} Target: {2}]", new Object[]{getSourceIndex(), getSource(), targetMsg}); }
private void writeObject(java.io.ObjectOutputStream oos) throws IOException { boolean wasNull = null == targetIndex; try { this.targetIndex = new TargetIndex(getTargetPOS(), getTargetOffset(), getTargetIndex()); } catch (JWNLException e) { throw new JWNLRuntimeException(e); } oos.defaultWriteObject(); if (wasNull) { this.targetIndex = null; } } }
for (Pointer p : synset.getPointers()) { result.append(p.getType().getKey()).append(' '); formatOffset(p.getTargetOffset(), offsetLength, result); result.append(' '); result.append(p.getTargetPOS().getKey()).append(' '); if (checkPointerIndexLimit && log.isWarnEnabled() && (0xFF < p.getSourceIndex())) { log.warn(dictionary.getMessages().resolveMessage("PRINCETON_WARN_006", new Object[]{synset.getOffset(), p.getSource().getSynset().getOffset(), p.getSourceIndex()})); if (checkPointerIndexLimit && log.isWarnEnabled() && (0xFF < p.getTargetIndex())) { log.warn(dictionary.getMessages().resolveMessage("PRINCETON_WARN_006", new Object[]{synset.getOffset(), p.getTarget().getSynset().getOffset(), p.getTargetIndex()})); if (p.getSourceIndex() < 0x10) { result.append("0"); result.append(Integer.toHexString(p.getSourceIndex())); if (p.getTargetIndex() < 0x10) { result.append("0"); result.append(Integer.toHexString(p.getTargetIndex())).append(' ');
for (Pointer pointer : pointers) { synsetPointerStmt.setInt(1, nextId()); synsetPointerStmt.setString(3, pointer.getType().getKey()); synsetPointerStmt.setLong(4, pointer.getTargetOffset()); synsetPointerStmt.setString(5, pointer.getTargetPOS().getKey()); synsetPointerStmt.setInt(6, pointer.getSourceIndex()); synsetPointerStmt.setInt(7, pointer.getTargetIndex()); synsetPointerStmt.addBatch();
/** * Returns the synset that is a) the target of this pointer, or b) the synset that contains the target of this pointer. * * @return the synset that is a) the target of this pointer, or b) the synset that contains the target of this pointer. * @throws JWNLException JWNLException */ public Synset getTargetSynset() throws JWNLException { if (null == getTarget()) { return null; } return getTarget().getSynset(); }
private void deleteSymmetricPointerFromTarget(Pointer original) { if (null != original.getType().getSymmetricType()) { try { for (Pointer p : original.getTargetSynset().getPointers()) { if (p.isSymmetricTo(original)) { original.getTargetSynset().getPointers().remove(p); break; } } } catch (JWNLException e) { throw new JWNLRuntimeException(e); } } }
if ((pointer.getSource() instanceof Word) && !indexWord.getLemma().equals(((Word) pointer.getSource()).getLemma().toLowerCase())) { continue; PointerType pt = pointer.getType(); char c = pointer.getType().getKey().charAt(0); if (';' == c || '-' == c || '@' == c || '~' == c) { pt = PointerType.getPointerTypeForKey(Character.toString(c));
/** * Returns all pointers of type <var>type</var>. * * @param type pointer type * @return all pointers of type <var>type</var> */ public List<Pointer> getPointers(PointerType type) { List<Pointer> result = new ArrayList<>(); for (Pointer pointer : getPointers()) { if (pointer.getType().equals(type) || PointerType.HYPERNYM == type && PointerType.INSTANCE_HYPERNYM == pointer.getType() || PointerType.HYPONYM == type && PointerType.INSTANCES_HYPONYM == pointer.getType()) { result.add(pointer); } } return result; }
@Override public String transform(Pointer p) { Synset source; PointerTarget pt = p.getSource(); if (pt instanceof Word) { source = ((Word) pt).getSynset(); } else { source = (Synset) pt; } try { return synsetToString.transform(source) + " -> " + synsetToString.transform(p.getTargetSynset()); } catch (JWNLException e) { throw new IllegalArgumentException(e); } } }
@Override public Set<String> getNeighbours() throws SenseInventoryException { if (neighbours != null) { return neighbours; } neighbours = new HashSet<String>(); // Add neighbours for (Pointer pointer : synset.getPointers()) { try { neighbours.add(synsetToString.transform(pointer .getTargetSynset())); } catch (JWNLException e) { throw new SenseInventoryException(e); } } return neighbours; } }
synset.getPointers().add(new Pointer(synset, type, targetPOS, targetOffset, targetIndex));
/** * Returns all the pointers of the synset that contains this word whose source is this word. */ public List<Pointer> getPointers() { List<Pointer> result = new ArrayList<>(0); for (Pointer pointer : getSynset().getPointers()) { if (this.equals(pointer.getSource())) { result.add(pointer); } } return result; }
for (Pointer p : synset.getPointers()) { result.append(p.getType().getKey()).append(' '); formatOffset(p.getTargetOffset(), offsetLength, result); result.append(' '); result.append(p.getTargetPOS().getKey()).append(' '); if (checkPointerIndexLimit && log.isWarnEnabled() && (0xFF < p.getSourceIndex())) { log.warn(dictionary.getMessages().resolveMessage("PRINCETON_WARN_006", new Object[]{synset.getOffset(), p.getSource().getSynset().getOffset(), p.getSourceIndex()})); if (checkPointerIndexLimit && log.isWarnEnabled() && (0xFF < p.getTargetIndex())) { log.warn(dictionary.getMessages().resolveMessage("PRINCETON_WARN_006", new Object[]{synset.getOffset(), p.getTarget().getSynset().getOffset(), p.getTargetIndex()})); if (p.getSourceIndex() < 0x10) { result.append("0"); result.append(Integer.toHexString(p.getSourceIndex())); if (p.getTargetIndex() < 0x10) { result.append("0"); result.append(Integer.toHexString(p.getTargetIndex())).append(' ');
for (Pointer pointer : pointers) { synsetPointerStmt.setInt(1, nextId()); synsetPointerStmt.setString(3, pointer.getType().getKey()); synsetPointerStmt.setLong(4, pointer.getTargetOffset()); synsetPointerStmt.setString(5, pointer.getTargetPOS().getKey()); synsetPointerStmt.setInt(6, pointer.getSourceIndex()); synsetPointerStmt.setInt(7, pointer.getTargetIndex()); synsetPointerStmt.addBatch();
/** * Returns the synset that is a) the target of this pointer, or b) the synset that contains the target of this pointer. * * @return the synset that is a) the target of this pointer, or b) the synset that contains the target of this pointer. * @throws JWNLException JWNLException */ public Synset getTargetSynset() throws JWNLException { if (null == getTarget()) { return null; } return getTarget().getSynset(); }
private void writeObject(java.io.ObjectOutputStream oos) throws IOException { boolean wasNull = null == targetIndex; try { this.targetIndex = new TargetIndex(getTargetPOS(), getTargetOffset(), getTargetIndex()); } catch (JWNLException e) { throw new JWNLRuntimeException(e); } oos.defaultWriteObject(); if (wasNull) { this.targetIndex = null; } } }