/** * Adds a new span to this view with a given label and score and returns the newly created * constituent. * <p> * If this {@code SpanLabelView} was defined not to accept overlapping spans (in the * constructor), then this function will throw an {@link IllegalArgumentException} when an * attempt is made to label an already existing span. * * @param start the start of the span * @param end the end of the span * @param label the label of the span * @param score the score assigned to this label * @return the newly created constituent that labels the given span. */ public Constituent addSpanLabel(int start, int end, String label, double score) { Constituent c = new Constituent(label, score, this.getViewName(), this.getTextAnnotation(), start, end); if (!allowOverlappingSpans && this.getConstituentsCoveringSpan(start, end).size() != 0) throw new IllegalArgumentException("Span [" + start + ", " + end + "] already labeled."); this.addConstituent(c); return c; }
/** * Adds a new span to this view with a given label and score and returns the newly created * constituent. * <p> * If this {@code SpanLabelView} was defined not to accept overlapping spans (in the * constructor), then this function will throw an {@link IllegalArgumentException} when an * attempt is made to label an already existing span. * * @param start the start of the span * @param end the end of the span * @param label the label of the span * @param score the score assigned to this label * @return the newly created constituent that labels the given span. */ public Constituent addSpanLabel(int start, int end, String label, double score) { Constituent c = new Constituent(label, score, this.getViewName(), this.getTextAnnotation(), start, end); if (!allowOverlappingSpans && this.getConstituentsCoveringSpan(start, end).size() != 0) throw new IllegalArgumentException("Span [" + start + ", " + end + "] already labeled."); this.addConstituent(c); return c; }