public String getLabel() { return this.textAnnotation.symtab.getLabel(label); }
public TextAnnotation(String corpusId, String id, String text, IntPair[] characterOffsets, String[] tokens, int[] sentenceEndPositions) { super(); // if the string is non-empty, the position of the last element should equal to the number of tokens if (tokens.length > 0 && sentenceEndPositions[sentenceEndPositions.length - 1] != tokens.length) throw new IllegalArgumentException("Invalid sentence boundary. " + "Last element should be the number of tokens"); this.corpusId = corpusId; this.id = id; this.text = text; this.symtab = new SymbolTable(); this.setTokens(tokens, characterOffsets); SpanLabelView view = new SpanLabelView(ViewNames.SENTENCE, "UserSpecified", this, 1d); int start = 0; for (int s : sentenceEndPositions) { view.addSpanLabel(start, s, ViewNames.SENTENCE, 1d); start = s; } this.addView(ViewNames.SENTENCE, view); // Add a TOKENS view in order to access tokens the same way as everything else in the // sentence TokenLabelView tokenLabelView = new TokenLabelView(ViewNames.TOKENS, "UserSpecified", this, 1d); for (int i = 0; i < tokens.length; i++) { tokenLabelView.addConstituent(new Constituent("", ViewNames.TOKENS, this, i, i + 1)); } this.addView(ViewNames.TOKENS, tokenLabelView); }
public TextAnnotation(String corpusId, String id, String text, IntPair[] characterOffsets, String[] tokens, int[] sentenceEndPositions) { super(); // if the string is non-empty, the position of the last element should equal to the number of tokens if (tokens.length > 0 && sentenceEndPositions[sentenceEndPositions.length - 1] != tokens.length) throw new IllegalArgumentException("Invalid sentence boundary. " + "Last element should be the number of tokens"); this.corpusId = corpusId; this.id = id; this.text = text; this.symtab = new SymbolTable(); this.setTokens(tokens, characterOffsets); SpanLabelView view = new SpanLabelView(ViewNames.SENTENCE, "UserSpecified", this, 1d); int start = 0; for (int s : sentenceEndPositions) { view.addSpanLabel(start, s, ViewNames.SENTENCE, 1d); start = s; } this.addView(ViewNames.SENTENCE, view); // Add a TOKENS view in order to access tokens the same way as everything else in the // sentence TokenLabelView tokenLabelView = new TokenLabelView(ViewNames.TOKENS, "UserSpecified", this, 1d); for (int i = 0; i < tokens.length; i++) { tokenLabelView.addConstituent(new Constituent("", ViewNames.TOKENS, this, i, i + 1)); } this.addView(ViewNames.TOKENS, tokenLabelView); }
public String getLabel() { return this.textAnnotation.symtab.getLabel(label); }
/** * private constructor to enable immutable label to score map * * @param labelsToScores map from labels to scores. * @param relationName name of relation * @param source constituent that is the source of the relation * @param target constituent that is the target of the relation * @param score confidence score for relation */ private Relation(Map<String, Double> labelsToScores, String relationName, double score, Constituent source, Constituent target) { if ( null != labelsToScores) { this.labelsToScores = Maps.newHashMap(); this.labelsToScores.putAll(labelsToScores); } else this.labelsToScores = null; TextAnnotation ta = source.getTextAnnotation(); assert ta == target.getTextAnnotation(); if (relationName == null) relationName = ""; int r = ta.symtab.getId(relationName); if (r == -1) r = ta.symtab.add(relationName); this.relationName = r; this.source = source; this.target = target; this.score = score; this.source.registerRelationSource(this); this.target.registerRelationTarget(this); }
public String getRelationName() { return source.getTextAnnotation().symtab.getLabel(relationName); }
/** * private constructor to enable immutable label to score map * * @param labelsToScores map from labels to scores. * @param relationName name of relation * @param source constituent that is the source of the relation * @param target constituent that is the target of the relation * @param score confidence score for relation */ private Relation(Map<String, Double> labelsToScores, String relationName, double score, Constituent source, Constituent target) { if ( null != labelsToScores) { this.labelsToScores = Maps.newHashMap(); this.labelsToScores.putAll(labelsToScores); } else this.labelsToScores = null; TextAnnotation ta = source.getTextAnnotation(); assert ta == target.getTextAnnotation(); if (relationName == null) relationName = ""; int r = ta.symtab.getId(relationName); if (r == -1) r = ta.symtab.add(relationName); this.relationName = r; this.source = source; this.target = target; this.score = score; this.source.registerRelationSource(this); this.target.registerRelationTarget(this); }
public String getRelationName() { return source.getTextAnnotation().symtab.getLabel(relationName); }