public static List<Constituent> getConstituentsInBetween(SpanLabelView view, int start, int end) { List<Constituent> output = view.getConstituentsCoveringSpan(start, end); List<Constituent> restrictedOutput = new ArrayList<>(); for (Constituent c : output) { if ((c.getStartSpan() >= start) && (c.getEndSpan() <= end)) restrictedOutput.add(c); } return restrictedOutput; }
public static List<Constituent> getConstituentsInBetween(SpanLabelView view, int start, int end) { List<Constituent> output = view.getConstituentsCoveringSpan(start, end); List<Constituent> restrictedOutput = new ArrayList<>(); for (Constituent c : output) { if ((c.getStartSpan() >= start) && (c.getEndSpan() <= end)) restrictedOutput.add(c); } return restrictedOutput; }
/** * 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; }
continue; if (startWord <= endWord && nerView.getConstituentsCoveringSpan(startWord, endWord + 1).isEmpty()) nerView.addSpanLabel(startWord, endWord + 1, nelabel, 1.0);
continue; if (startWord <= endWord && nerView.getConstituentsCoveringSpan(startWord, endWord + 1).isEmpty()) nerView.addSpanLabel(startWord, endWord + 1, nelabel, 1.0);
existsSpan = view.getConstituentsCoveringSpan(tokenId, endTokenId + 1).size() > 0;
existsSpan = view.getConstituentsCoveringSpan(tokenId, endTokenId + 1).size() > 0;
existsSpan = view.getConstituentsCoveringSpan(tokenId, endTokenId + 1).size() > 0;