/** * Returns all the pointer targets of this synset. * * @return all the pointer targets of this synset * @throws JWNLException JWNLException */ public List<PointerTarget> getTargets() throws JWNLException { return collectTargets(getPointers()); }
public POS getTargetPOS() throws JWNLException { if (null == target) { if (null != source.getDictionary() && source.getDictionary().isEditable()) { return getTarget().getSynset().getPOS(); } else { return targetIndex.pos; } } else { return target.getSynset().getPOS(); } }
public int getTargetIndex() throws JWNLException { if (null == target) { if (null != source.getDictionary() && source.getDictionary().isEditable()) { return getTarget().getIndex(); } else { return targetIndex.index; } } else { return target.getIndex(); } }
/** * This method consumes a lexical pointer and generates the associated RelatedForm, defined in Uby-LMF * @param pointer WordNet's lexical pointer * @return RelatedForm associated with the consumed pointer * @see RelatedForm * @see Pointer */ private RelatedForm generateRelatedForm(Pointer pointer){ RelatedForm relatedForm = new RelatedForm(); // setting RelationType ERelTypeMorphology relType = getRelType(pointer.getType().getKey(), POS.getAllPOS().indexOf(pointer.getSource().getPOS())); relatedForm.setRelType(relType); // setting targetSense Word targetLexeme = (Word) pointer.getTarget(); relatedForm.setTargetSense(lexicalEntryGenerator.getSenseGenerator().getSense(targetLexeme)); // setting targeted LexicalEntry LexicalEntry targetLexicalEntry = lexicalEntryGenerator.getLexicalEntry(targetLexeme); if (targetLexicalEntry == null) throw new NullPointerException("Unable to find target lexical entry of related form for " + targetLexeme); relatedForm.setTargetLexicalEntry(targetLexicalEntry); return relatedForm; }
/** * If the target is a synset, return it, otherwise it's a word * so return the word's parent synset. * * @return If the target is a synset, return it, otherwise it's a word so return the word's parent synset */ public Synset getSynset() { return target.getSynset(); }
/** * Returns the actual target of this pointer. * * @return actual target of this pointer * @throws JWNLException JWNLException */ public PointerTarget getTarget() throws JWNLException { if (null == target && null != source.getDictionary()) { Synset syn = source.getDictionary().getSynsetAt(targetIndex.pos, targetIndex.offset); target = (targetIndex.index == 0) ? syn : (null == syn ? null : syn.getWords().get(targetIndex.index - 1)); if (null != target && source.getDictionary().isEditable()) { targetIndex = null; } } return target; }
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}); }
public int getSourceIndex() { return source.getIndex(); }
@Override public void setDictionary(Dictionary dictionary) throws JWNLException { if (dictionary != this.dictionary) { if (null != this.dictionary) { Dictionary old = this.dictionary; this.dictionary = dictionary; old.removeElement(this); } super.setDictionary(dictionary); if (null != dictionary) { dictionary.addElement(this); } } }
/** * 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; }
/** * This method creates a SenseRelation based on the consumed WordNet-pointer * @param pointer WordNet's {@link Pointer} * @return instance of {@link SenseRelation}-class associated with the consumed pointer */ private SenseRelation createSenseRelation(Pointer pointer){ SenseRelation senseRelation = new SenseRelation(); // Setting the target Word target = (Word) pointer.getTarget(); senseRelation.setTarget(lexicalEntryGenerator.getSenseGenerator().getSense(target)); String pointerKey = pointer.getType().getKey(); int posOrdinal = POS.getAllPOS().indexOf(pointer.getSource().getPOS()); // setting RelationName String relName = getRelName(pointerKey, posOrdinal); senseRelation.setRelName(relName); // settin relation type ERelTypeSemantics relType = getRelType(pointerKey, posOrdinal); senseRelation.setRelType(relType); return senseRelation; }
/** * If the target is a synset, return it, otherwise it's a word * so return the word's parent synset. * * @return If the target is a synset, return it, otherwise it's a word so return the word's parent synset */ public Synset getSynset() { return target.getSynset(); }
/** * Returns the actual target of this pointer. * * @return actual target of this pointer * @throws JWNLException JWNLException */ public PointerTarget getTarget() throws JWNLException { if (null == target && null != source.getDictionary()) { Synset syn = source.getDictionary().getSynsetAt(targetIndex.pos, targetIndex.offset); target = (targetIndex.index == 0) ? syn : (null == syn ? null : syn.getWords().get(targetIndex.index - 1)); if (null != target && source.getDictionary().isEditable()) { targetIndex = null; } } return target; }
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}); }
public int getSourceIndex() { return source.getIndex(); }
@Override public void setDictionary(Dictionary dictionary) throws JWNLException { if (dictionary != this.dictionary) { if (null != this.dictionary) { Dictionary old = this.dictionary; this.dictionary = dictionary; old.removeElement(this); } super.setDictionary(dictionary); if (null != dictionary) { dictionary.addElement(this); } } }
/** * 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; }
/** * Returns all the targets of the pointers of type <var>type</var>. * * @param type pointer type * @return all the targets of the pointers of type <var>type</var> * @throws JWNLException JWNLException */ public List<PointerTarget> getTargets(PointerType type) throws JWNLException { return collectTargets(getPointers(type)); }