private int getLabelId(String label, TextAnnotation text) { if (label == null) label = ""; int labelId = text.symtab.getId(label); if (labelId == -1) labelId = text.symtab.add(label); return labelId; }
private int getLabelId(String label, TextAnnotation text) { if (label == null) label = ""; int labelId = text.symtab.getId(label); if (labelId == -1) labelId = text.symtab.add(label); return labelId; }
/** * 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); }
/** * 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); }