/** * Gets the parent of a constituent. It is assumed that the input constiutent is a member of a * TreeView. */ public static Constituent getParent(Constituent constituent) { return constituent.getIncomingRelations().get(0).getSource(); }
/** * Gets the parent of a constituent. It is assumed that the input constiutent is a member of a * TreeView. */ public static Constituent getParent(Constituent constituent) { return constituent.getIncomingRelations().get(0).getSource(); }
@Override public Boolean transform(Constituent p) { boolean found = false; for (Relation r : c.getIncomingRelations()) { if (r.getSource() == p) { found = true; break; } } return found; } };
@Override public List<Constituent> transform(Constituent input) { List<Constituent> c = new ArrayList<>(); for (Relation r : input.getIncomingRelations()) { c.add(addPointerToSource(input, r.getSource())); } return c; }
@Override public Boolean transform(Constituent p) { boolean found = false; for (Relation r : c.getIncomingRelations()) { if (r.getSource() == p) { found = true; break; } } return found; } };
@Override public List<Constituent> transform(Constituent input) { List<Constituent> c = new ArrayList<>(); for (Relation r : input.getIncomingRelations()) { c.add(addPointerToSource(input, r.getSource())); } return c; }
public static Constituent getPredicate(Constituent argument) { return argument.getIncomingRelations().get(0).getSource(); }
public static Constituent getPredicate(Constituent argument) { return argument.getIncomingRelations().get(0).getSource(); }
private static List<Constituent> getGovernor(Constituent input, TreeView dependency) { List<Constituent> constituentsCovering = dependency.getConstituentsCovering(input); if (constituentsCovering.size() == 0) return new ArrayList<>(); Constituent c = constituentsCovering.get(0); List<Relation> incomingRelations = c.getIncomingRelations(); if (incomingRelations == null || incomingRelations.size() == 0) return new ArrayList<>(); else return Collections.singletonList(addPointerToSource(input, incomingRelations.get(0) .getSource())); }
private static List<Constituent> getGovernor(Constituent input, TreeView dependency) { List<Constituent> constituentsCovering = dependency.getConstituentsCovering(input); if (constituentsCovering.size() == 0) return new ArrayList<>(); Constituent c = constituentsCovering.get(0); List<Relation> incomingRelations = c.getIncomingRelations(); if (incomingRelations == null || incomingRelations.size() == 0) return new ArrayList<>(); else return Collections.singletonList(addPointerToSource(input, incomingRelations.get(0) .getSource())); }
public String discreteValue(Object __example) { if (!(__example instanceof Relation)) { String type = __example == null ? "null" : __example.getClass().getName(); System.err.println("Classifier 'afterHead(Relation)' defined on line 26 of extent.lbj received '" + type + "' as input."); new Exception().printStackTrace(); System.exit(1); } Relation r = (Relation) __example; if (r.getSource().getStartSpan() >= r.getTarget().getEndSpan()) { return "true"; } return "false"; }
public static String printRelation(Relation c) { StringBuilder output = new StringBuilder(); output.append( "Relation has type: " ); output.append( c.getRelationName() ); output.append( "Attributes: "); for ( String attType : c.getAttributeKeys() ) { String val = c.getAttribute( attType ); output.append( "[").append( attType ).append( ", " ).append( val ).append( "], " ); } output.append("\nFirst argument:\n"); output.append(printConstituent(c.getSource())); output.append("\n\nSecond argument:\n"); output.append(printConstituent(c.getTarget())); return output.toString(); }
public static String printRelation(Relation c) { StringBuilder output = new StringBuilder(); output.append( "Relation has type: " ); output.append( c.getRelationName() ); output.append( "Attributes: "); for ( String attType : c.getAttributeKeys() ) { String val = c.getAttribute( attType ); output.append( "[").append( attType ).append( ", " ).append( val ).append( "], " ); } output.append("\nFirst argument:\n"); output.append(printConstituent(c.getSource())); output.append("\n\nSecond argument:\n"); output.append(printConstituent(c.getTarget())); return output.toString(); }
@Override public int hashCode() { int hashCode = this.getRelationName().hashCode() * 79 + this.getSource().hashCode() * 7 + this.getTarget().hashCode() * 13 + (new Double(this.getScore())).hashCode() * 17; hashCode += (this.attributes == null ? 0 : this.attributes.hashCode() * 13); hashCode += (this.labelsToScores == null ? 0 : this.labelsToScores.hashCode() * 23); return hashCode; }
@Override public int hashCode() { int hashCode = this.getRelationName().hashCode() * 79 + this.getSource().hashCode() * 7 + this.getTarget().hashCode() * 13 + (new Double(this.getScore())).hashCode() * 17; hashCode += (this.attributes == null ? 0 : this.attributes.hashCode() * 13); hashCode += (this.labelsToScores == null ? 0 : this.labelsToScores.hashCode() * 23); return hashCode; }
@Override public Set<Feature> getFeatures(Constituent c) throws EdisonException { List<Relation> incomingRelation = c.getIncomingRelations(); Set<Feature> features = new LinkedHashSet<>(); if (incomingRelation.size() > 0) { Constituent predicate = incomingRelation.get(0).getSource(); if (predicate.getStartSpan() >= c.getEndSpan()) features.add(BEFORE); else if (c.getStartSpan() >= predicate.getEndSpan()) features.add(AFTER); else features.add(CONTAINS); } return features; }
@Override public Set<Feature> getFeatures(Constituent c) throws EdisonException { List<Relation> incomingRelation = c.getIncomingRelations(); Set<Feature> features = new LinkedHashSet<>(); if (incomingRelation.size() > 0) { Constituent predicate = incomingRelation.get(0).getSource(); if (predicate.getStartSpan() >= c.getEndSpan()) features.add(BEFORE); else if (c.getStartSpan() >= predicate.getEndSpan()) features.add(AFTER); else features.add(CONTAINS); } return features; }
/** * Lexical Feature Extractor Part A * @Extract source mention BOW * @return A List of String features */ public List<String> getLexicalFeaturePartA(Relation r){ List<String> ret_features = new ArrayList<String>(); Constituent source = r.getSource(); TextAnnotation ta = source.getTextAnnotation(); for (int i = source.getStartSpan(); i < source.getEndSpan(); i++){ ret_features.add(ta.getToken(i)); } return ret_features; }
/** * required: consMap *must* contain the source and target constituents for r as keys, and their values * must be non-null * @param r relation to copy * @param consMap map from original constituents to new counterparts * @return new relation with all info copied from original, but with new source and target constituents */ public static Relation copyRelation(Relation r, Map<Constituent, Constituent> consMap) { Relation newRel = null; if ( null == r.getLabelsToScores() ) newRel = new Relation(r.getRelationName(), consMap.get(r.getSource()), consMap.get(r.getTarget()), r.getScore()); else newRel = new Relation(r.getLabelsToScores(), consMap.get(r.getSource()), consMap.get(r.getTarget())); copyAttributesFromTo(r, newRel); return newRel; }
/** * Checks if the two mentions are co-referencing each other * @return A boolean */ public String getCorefTag(Relation r){ Constituent source = r.getSource(); Constituent target = r.getTarget(); if (source.getAttribute("EntityID") != null && target.getAttribute("EntityID") != null) { if (source.getAttribute("EntityID").equals(target.getAttribute("EntityID"))) { return "TRUE"; } } return "FALSE"; }