public static String printConstituent( Constituent c ) { StringBuilder output = new StringBuilder(); output.append( "Constituent: Surface form: " ).append("'").append( c.getSurfaceForm() ).append( "'" ); // output.append( "\ns-exp: " ); // output.append( c_.toSExpression( true ) ); output.append( "\nLabel: " ).append( c.getLabel() ).append( "; view: " ).append( c.getViewName() ); output.append( "\n" ).append( "char offsets: " ).append( c.getStartCharOffset() ).append( ", " ); output.append( c.getEndCharOffset() ).append( "\ntoken offsets: " ).append( c.getStartSpan() ); output.append( ", " ).append( c.getEndSpan() ); output.append( "\nAttributes: "); for ( String attType : c.getAttributeKeys() ) { String val = c.getAttribute( attType ); output.append( "[").append( attType ).append( ", " ).append( val ).append( "], " ); } output.append( "\nLabel Scores: " ); Map<String, Double> labelsToScores = c.getLabelsToScores(); if ( null != labelsToScores ) for ( Map.Entry<String, Double> e : labelsToScores.entrySet() ) output.append(e.getKey()).append(": ").append(e.getValue()).append(", "); else output.append(c.getLabel()).append(": ").append(c.getConstituentScore()); output.append( "\n" ); return output.toString(); }
public static String printConstituent( Constituent c ) { StringBuilder output = new StringBuilder(); output.append( "Constituent: Surface form: " ).append("'").append( c.getSurfaceForm() ).append( "'" ); // output.append( "\ns-exp: " ); // output.append( c_.toSExpression( true ) ); output.append( "\nLabel: " ).append( c.getLabel() ).append( "; view: " ).append( c.getViewName() ); output.append( "\n" ).append( "char offsets: " ).append( c.getStartCharOffset() ).append( ", " ); output.append( c.getEndCharOffset() ).append( "\ntoken offsets: " ).append( c.getStartSpan() ); output.append( ", " ).append( c.getEndSpan() ); output.append( "\nAttributes: "); for ( String attType : c.getAttributeKeys() ) { String val = c.getAttribute( attType ); output.append( "[").append( attType ).append( ", " ).append( val ).append( "], " ); } output.append( "\nLabel Scores: " ); Map<String, Double> labelsToScores = c.getLabelsToScores(); if ( null != labelsToScores ) for ( Map.Entry<String, Double> e : labelsToScores.entrySet() ) output.append(e.getKey()).append(": ").append(e.getValue()).append(", "); else output.append(c.getLabel()).append(": ").append(c.getConstituentScore()); output.append( "\n" ); return output.toString(); }
private static void writeConstituent(Constituent c, JsonObject cJ) { writeString("label", c.getLabel(), cJ); if (c.getConstituentScore() != 0) writeDouble("score", c.getConstituentScore(), cJ); writeInt("start", c.getStartSpan(), cJ); writeInt("end", c.getEndSpan(), cJ); writeAttributes(c, cJ); Map<String, Double> labelsToScores = c.getLabelsToScores(); if ( null != labelsToScores ) writeLabelsToScores(labelsToScores, cJ); }
private static void writeConstituent(Constituent c, JsonObject cJ) { writeString("label", c.getLabel(), cJ); if (c.getConstituentScore() != 0) writeDouble("score", c.getConstituentScore(), cJ); writeInt("start", c.getStartSpan(), cJ); writeInt("end", c.getEndSpan(), cJ); writeAttributes(c, cJ); Map<String, Double> labelsToScores = c.getLabelsToScores(); if ( null != labelsToScores ) writeLabelsToScores(labelsToScores, cJ); }
try { String lbl = c.getLabel(); tv.addSpanLabel(start, end, lbl, c.getConstituentScore()); } catch (IllegalArgumentException iae) { logger.error("Overlapping labels are not supported.", iae);
for (int i = 0; i < corefMentions.size(); i++) { Constituent cons = corefMentions.get(i); scores[i] = cons.getConstituentScore(); for (int i = 0; i < corefMentionHeads.size(); i++) { Constituent cons = corefMentionHeads.get(i); scores[i] = cons.getConstituentScore();
for (int i = 0; i < corefMentions.size(); i++) { Constituent cons = corefMentions.get(i); scores[i] = cons.getConstituentScore(); for (int i = 0; i < corefMentionHeads.size(); i++) { Constituent cons = corefMentionHeads.get(i); scores[i] = cons.getConstituentScore();
public Constituent cloneForNewViewWithDestinationLabel(String newViewName, String Dlabel) { Constituent cloneC = new Constituent(this.labelsToScores, Dlabel, this.getConstituentScore(), newViewName, this.getTextAnnotation(), this.getStartSpan(), this.getEndSpan()); for (String k : this.getAttributeKeys()) { cloneC.addAttribute(k, this.getAttribute(k)); } return cloneC; }
public Constituent cloneForNewViewWithDestinationLabel(String newViewName, String Dlabel) { Constituent cloneC = new Constituent(this.labelsToScores, Dlabel, this.getConstituentScore(), newViewName, this.getTextAnnotation(), this.getStartSpan(), this.getEndSpan()); for (String k : this.getAttributeKeys()) { cloneC.addAttribute(k, this.getAttribute(k)); } return cloneC; }
for (int i = 0; i < corefMentions.size(); i++) { Constituent cons = corefMentions.get(i); scores[i] = cons.getConstituentScore(); for (int i = 0; i < corefMentionHeads.size(); i++) { Constituent cons = corefMentionHeads.get(i); scores[i] = cons.getConstituentScore();
public Constituent cloneForNewView(String newViewName) { Constituent cloneC = new Constituent(this.labelsToScores, this.getLabel(), this.getConstituentScore(), newViewName, this.getTextAnnotation(), this.getStartSpan(), this.getEndSpan()); for (String k : this.getAttributeKeys()) { cloneC.addAttribute(k, this.getAttribute(k)); } return cloneC; }
public Constituent cloneForNewView(String newViewName) { Constituent cloneC = new Constituent(this.labelsToScores, this.getLabel(), this.getConstituentScore(), newViewName, this.getTextAnnotation(), this.getStartSpan(), this.getEndSpan()); for (String k : this.getAttributeKeys()) { cloneC.addAttribute(k, this.getAttribute(k)); } return cloneC; }
combinedSent = new Constituent(first.getLabel(), first.getConstituentScore(), ViewNames.SENTENCE, first.getTextAnnotation(), first.getStartSpan(), second.getEndSpan()); else
combinedSent = new Constituent(first.getLabel(), first.getConstituentScore(), ViewNames.SENTENCE, first.getTextAnnotation(), first.getStartSpan(), second.getEndSpan()); else
/** * create a new constituent with token offsets shifted by the specified amount * @param newTA TextAnnotation which will contain the new Constituent * @param c original Constituent to copy * @param offset the offset to shift token indexes of new Constituent. Can be negative. * @return the new Constituent */ public static Constituent copyConstituentWithNewTokenOffsets(TextAnnotation newTA, Constituent c, int offset) { int newStart = c.getStartSpan() + offset; int newEnd = c.getEndSpan() + offset; assert(newStart >= 0 && newStart <= newTA.size()); assert(newEnd >= 0 && newEnd <= newTA.size()); Constituent newCon = null; if (null != c.getLabelsToScores()) newCon = new Constituent(c.getLabelsToScores(), c.viewName, newTA, newStart, newEnd); else newCon = new Constituent(c.getLabel(), c.getConstituentScore(), c.viewName, newTA, newStart, newEnd); copyAttributesFromTo(c, newCon); return newCon; }
/** * create a new constituent with token offsets shifted by the specified amount * @param newTA TextAnnotation which will contain the new Constituent * @param c original Constituent to copy * @param offset the offset to shift token indexes of new Constituent. Can be negative. * @return the new Constituent */ public static Constituent copyConstituentWithNewTokenOffsets(TextAnnotation newTA, Constituent c, int offset) { int newStart = c.getStartSpan() + offset; int newEnd = c.getEndSpan() + offset; assert(newStart >= 0 && newStart <= newTA.size()); assert(newEnd >= 0 && newEnd <= newTA.size()); Constituent newCon = null; if (null != c.getLabelsToScores()) newCon = new Constituent(c.getLabelsToScores(), c.viewName, newTA, newStart, newEnd); else newCon = new Constituent(c.getLabel(), c.getConstituentScore(), c.viewName, newTA, newStart, newEnd); copyAttributesFromTo(c, newCon); return newCon; }
private static void writeConstituent(Constituent constituent, ViewDataProto.Builder viewDataBuilder) { ConstituentProto.Builder constituentBuilder = ConstituentProto.newBuilder(); constituentBuilder.setLabel(constituent.getLabel()); constituentBuilder.setScore(constituent.getConstituentScore()); constituentBuilder.setStart(constituent.getStartSpan()); constituentBuilder.setEnd(constituent.getEndSpan()); if (constituent.getAttributeKeys().size() > 0) { for (String key : Sorters.sortSet(constituent.getAttributeKeys())) { constituentBuilder.putProperties(key, constituent.getAttribute(key)); } } Map<String, Double> labelsToScores = constituent.getLabelsToScores(); if (labelsToScores != null) { constituentBuilder.putAllLabelScoreMap(labelsToScores); } viewDataBuilder.addConstituents(constituentBuilder); }
private static void writeConstituent(Constituent constituent, ViewDataProto.Builder viewDataBuilder) { ConstituentProto.Builder constituentBuilder = ConstituentProto.newBuilder(); constituentBuilder.setLabel(constituent.getLabel()); constituentBuilder.setScore(constituent.getConstituentScore()); constituentBuilder.setStart(constituent.getStartSpan()); constituentBuilder.setEnd(constituent.getEndSpan()); if (constituent.getAttributeKeys().size() > 0) { for (String key : Sorters.sortSet(constituent.getAttributeKeys())) { constituentBuilder.putProperties(key, constituent.getAttribute(key)); } } Map<String, Double> labelsToScores = constituent.getLabelsToScores(); if (labelsToScores != null) { constituentBuilder.putAllLabelScoreMap(labelsToScores); } viewDataBuilder.addConstituents(constituentBuilder); }