@Override protected Predicate<Constituent> getQuery(List<String> args, Constituent c) { return Queries.sameSpanAsConstituent(c); } });
@Override protected Predicate<Constituent> getQuery(List<String> args, Constituent c) { return Queries.sameSpanAsConstituent(c); } });
/** * 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); }
@SuppressWarnings({"unchecked", "serial"}) private Constituent getParsePhraseSingeWordHack(Constituent c, Constituent phrase) { List<Constituent> candidates; if (phrase == null || !Queries.containsConstituent(phrase).transform(c)) { // a hack that deals with cases when a single word constituent is // not found in the parse tree because it is not a phrase. if (c.getStartSpan() == c.getEndSpan() - 1) { candidates = (List<Constituent>) this.where(Queries.sameSpanAsConstituent(c).and( new Predicate<Constituent>() { @Override public Boolean transform(Constituent input) { return input.getOutgoingRelations().size() > 0; } })); phrase = candidates.get(0); } } return phrase; }
@SuppressWarnings({"unchecked", "serial"}) private Constituent getParsePhraseSingeWordHack(Constituent c, Constituent phrase) { List<Constituent> candidates; if (phrase == null || !Queries.containsConstituent(phrase).transform(c)) { // a hack that deals with cases when a single word constituent is // not found in the parse tree because it is not a phrase. if (c.getStartSpan() == c.getEndSpan() - 1) { candidates = (List<Constituent>) this.where(Queries.sameSpanAsConstituent(c).and( new Predicate<Constituent>() { @Override public Boolean transform(Constituent input) { return input.getOutgoingRelations().size() > 0; } })); phrase = candidates.get(0); } } return phrase; }
public static Predicate<Constituent> exclusivelyOverlaps(Constituent argument) { return Queries.hasOverlap(argument).and(Queries.containedInConstituent(argument).negate()) .and(Queries.containsConstituent(argument).negate()) .and(Queries.sameSpanAsConstituent(argument).negate()); }
public static Predicate<Constituent> exclusivelyOverlaps(Constituent argument) { return Queries.hasOverlap(argument).and(Queries.containedInConstituent(argument).negate()) .and(Queries.containsConstituent(argument).negate()) .and(Queries.sameSpanAsConstituent(argument).negate()); }
condition = Queries.sameSpanAsConstituent(c);
condition = Queries.sameSpanAsConstituent(c);
@Override public Boolean transform(Pair<Constituent, SpanLabelView> input) { if (!types.contains(input.getFirst().getLabel())) return true; Constituent c = input.getFirst(); TextAnnotation ta = c.getTextAnnotation(); TreeView parse; if (ta.hasView(ViewNames.PARSE_CHARNIAK)) parse = (TreeView) ta.getView(ViewNames.PARSE_CHARNIAK); else if (ta.hasView(ViewNames.PARSE_BERKELEY)) parse = (TreeView) ta.getView(ViewNames.PARSE_BERKELEY); else if (ta.hasView(ViewNames.PARSE_STANFORD)) parse = (TreeView) ta.getView(ViewNames.PARSE_STANFORD); else return true; boolean foundNP = false; for (Constituent parseConstituent : parse.where(Queries .sameSpanAsConstituent(c))) { if (ParseTreeProperties.isNonTerminalNoun(parseConstituent.getLabel())) { foundNP = true; break; } } // do not include return foundNP; } };
@Override public Boolean transform(Pair<Constituent, SpanLabelView> input) { if (!types.contains(input.getFirst().getLabel())) return true; Constituent c = input.getFirst(); TextAnnotation ta = c.getTextAnnotation(); TreeView parse; if (ta.hasView(ViewNames.PARSE_CHARNIAK)) parse = (TreeView) ta.getView(ViewNames.PARSE_CHARNIAK); else if (ta.hasView(ViewNames.PARSE_BERKELEY)) parse = (TreeView) ta.getView(ViewNames.PARSE_BERKELEY); else if (ta.hasView(ViewNames.PARSE_STANFORD)) parse = (TreeView) ta.getView(ViewNames.PARSE_STANFORD); else return true; boolean foundNP = false; for (Constituent parseConstituent : parse.where(Queries .sameSpanAsConstituent(c))) { if (ParseTreeProperties.isNonTerminalNoun(parseConstituent.getLabel())) { foundNP = true; break; } } // do not include return foundNP; } };