/** * The view will consist of potentially overlapping constituents representing those tokens that * matched entries in the gazetteers. Some tokens will match against several gazetteers. */ @Override public void addView(TextAnnotation ta) throws AnnotatorException { View view = ta.getView(ViewNames.TOKENS); List<Constituent> constituents = view.getConstituents(); SpanLabelView slv = new SpanLabelView(this.getViewName(), this.getClass().getName(), ta, 1d, true); for (int constindx = 0; constindx < constituents.size(); constindx++) { for (int dictindx = 0; dictindx < dictionaries.size(); dictindx++) { dictionaries.get(dictindx).match(constituents, constindx, slv); dictionariesIgnoreCase.get(dictindx).match(constituents, constindx, slv); } } ta.addView(slv.getViewName(), slv); } }
/** * The view will consist of potentially overlapping constituents representing those tokens that * matched entries in the gazetteers. Some tokens will match against several gazetteers. */ @Override public void addView(TextAnnotation ta) throws AnnotatorException { View view = ta.getView(ViewNames.TOKENS); List<Constituent> constituents = view.getConstituents(); SpanLabelView slv = new SpanLabelView(this.getViewName(), this.getClass().getName(), ta, 1d, true); for (int constindx = 0; constindx < constituents.size(); constindx++) { for (int dictindx = 0; dictindx < dictionaries.size(); dictindx++) { dictionaries.get(dictindx).match(constituents, constindx, slv); dictionariesIgnoreCase.get(dictindx).match(constituents, constindx, slv); } } ta.addView(slv.getViewName(), slv); } }
/** * 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; }