/** * Returns ALL the constituents in a single chain characterized by its canonical constituent */ public Set<Constituent> getCoreferentMentionsViaRelations(Constituent mention) { Set<Constituent> canonicalMentionSet = getCanonicalEntitySetViaRelation(mention); Set<Constituent> coreferentMentions = new HashSet<>(); for (Constituent c : canonicalMentionSet) { for (Relation r : getFilteredOutgoingRelations(c)) { coreferentMentions.add(r.target); } } coreferentMentions.addAll(canonicalMentionSet); return coreferentMentions; }
/** * Returns ALL the constituents in a single chain characterized by its canonical constituent */ public Set<Constituent> getCoreferentMentionsViaRelations(Constituent mention) { Set<Constituent> canonicalMentionSet = getCanonicalEntitySetViaRelation(mention); Set<Constituent> coreferentMentions = new HashSet<>(); for (Constituent c : canonicalMentionSet) { for (Relation r : getFilteredOutgoingRelations(c)) { coreferentMentions.add(r.target); } } coreferentMentions.addAll(canonicalMentionSet); return coreferentMentions; }
@Override public String toString() { StringBuilder sb = new StringBuilder(); Set<Constituent> entities = this.getCanonicalEntities(); for (Constituent canonical : Sorters.sortSet(entities, TextAnnotationUtilities.constituentStartComparator)) { sb.append(canonical.toString()).append(" (").append(canonical.getStartSpan()) .append(", ").append(canonical.getEndSpan()).append(")\n"); for (Relation referant : getFilteredOutgoingRelations(canonical)) { sb.append("\t").append(referant.getTarget().toString()).append(" (") .append(referant.getTarget().getStartSpan()).append(", ") .append(referant.getTarget().getEndSpan()).append(") \n"); } sb.append("\n"); } return sb.toString(); }
/** * given the canonical constituent, returns back the constitunts connected to it. * * @param mention canonical mention * @return the connected constituents */ @Deprecated public List<Constituent> getCoreferentMentions(Constituent mention) { List<Constituent> myMentions = (List<Constituent>) this.where(Queries.sameSpanAsConstituent(mention)); if (myMentions.size() == 0) return Collections.singletonList(mention); // TODO: this would create problem in overlapping mentions Constituent myMention = myMentions.get(0); Constituent canonicalEntity = getCanonicalEntity(myMention); return Mappers.map(getFilteredOutgoingRelations(canonicalEntity), relationsToConstituents); }
/** * given the canonical constituent, returns back the constitunts connected to it. * * @param mention canonical mention * @return the connected constituents */ @Deprecated public List<Constituent> getCoreferentMentions(Constituent mention) { List<Constituent> myMentions = (List<Constituent>) this.where(Queries.sameSpanAsConstituent(mention)); if (myMentions.size() == 0) return Collections.singletonList(mention); // TODO: this would create problem in overlapping mentions Constituent myMention = myMentions.get(0); Constituent canonicalEntity = getCanonicalEntity(myMention); return Mappers.map(getFilteredOutgoingRelations(canonicalEntity), relationsToConstituents); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); Set<Constituent> entities = this.getCanonicalEntities(); for (Constituent canonical : Sorters.sortSet(entities, TextAnnotationUtilities.constituentStartComparator)) { sb.append(canonical.toString()).append(" (").append(canonical.getStartSpan()) .append(", ").append(canonical.getEndSpan()).append(")\n"); for (Relation referant : getFilteredOutgoingRelations(canonical)) { sb.append("\t").append(referant.getTarget().toString()).append(" (") .append(referant.getTarget().getStartSpan()).append(", ") .append(referant.getTarget().getEndSpan()).append(") \n"); } sb.append("\n"); } return sb.toString(); }
/** * Finds the representative elements for each cluster */ @Deprecated private void findCanonicalEntries() { if (this.canonicalEntitiesMap.size() > 0 || !this.modified) return; // The assumption is that all nodes with no parent are canonical entities. for (Constituent cc : this.getConstituents()) { int ccId = this.constituents.indexOf(cc); if (getFilteredIncomingRelations(cc).size() == 0) { canonicalEntitiesMap.put(ccId, ccId); for (Relation r : getFilteredOutgoingRelations(cc)) { int tId = this.constituents.indexOf(r.getTarget()); canonicalEntitiesMap.put(tId, ccId); } } } modified = false; }
/** * Finds the representative elements for each cluster */ @Deprecated private void findCanonicalEntries() { if (this.canonicalEntitiesMap.size() > 0 || !this.modified) return; // The assumption is that all nodes with no parent are canonical entities. for (Constituent cc : this.getConstituents()) { int ccId = this.constituents.indexOf(cc); if (getFilteredIncomingRelations(cc).size() == 0) { canonicalEntitiesMap.put(ccId, ccId); for (Relation r : getFilteredOutgoingRelations(cc)) { int tId = this.constituents.indexOf(r.getTarget()); canonicalEntitiesMap.put(tId, ccId); } } } modified = false; }