/** * Getter for the end character position of the text * @return the end character position */ public int getEndChar(){ return chunk.getEnd(); } /**
/** * Getter for the start character position * @return the start character position of the selected text span. */ public int getStartChar(){ return chunk.getStart(); } /**
/** * Getter for token text * @return the text of the token */ public String getTokenText(){ return token.getSpan(); } /**
private Occurrence(Section sentence,Token start,Token end){ this.start = start.getStart(); this.end = end.getEnd(); String context = sentence.getSpan(); if(context.length() > MAX_CONTEXT_LENGTH){ context = start.getContext().getSpan().substring( Math.max(0, this.start-CONTEXT_TOKEN_COUNT), Math.min(this.end+CONTEXT_TOKEN_COUNT, start.getContext().getEnd())-1); } this.context = context; } /**
/** * Checks the {@link #start} {@link #end} values against the span selected * by the parsed token.<p> * This method is called by all others that do add tokens. * @param token the added token */ private void checkSpan(Token token) { if(start > token.getStart()){ start = token.getStart(); } if(end < token.getEnd()){ end = token.getEnd(); } }
@Override public boolean evaluate(Object span) { return types.contains(((Span)span).getType()); } });
private void logAnnotations(AnalysedText at){ Iterator<Span> it = at.getEnclosed(EnumSet.of(SpanTypeEnum.Sentence, SpanTypeEnum.Token)); while(it.hasNext()){ Span span = it.next(); log.trace(" > {}",span); for(Value<PosTag> value : span.getAnnotations(POS_ANNOTATION)){ log.trace(" - {}",value); } } } /**
/** * The {@link AnalysedText Text} * @return the text */ public AnalysedText getAnalysedText(){ return token.getContext(); } /**
@Override public Span next() { hasNext(); //ensure hasNext is called on multiple calls to next() return level2It.next(); }
/** * Copies the elements of the parsed iterator(s) to a {@link SortedSet}. As * {@link Span} implements {@link Comparable} the Spans within the resulting * set will have the same order as returned by the methods of {@link AnalysedText} * @param it the iterator(s) * @return the {@link SortedSet} containing all Spans of the iterators */ public static <T extends Span> SortedSet<T> asSet(Iterator<T> it){ SortedSet<T> spans = new TreeSet<T>(); addToSet(it, spans); return spans; } /**
private Occurrence(Section sentence,Token start,Token end){ this.start = start.getStart(); this.end = end.getEnd(); String context = sentence.getSpan(); if(context.length() > MAX_CONTEXT_LENGTH){ context = start.getContext().getSpan().substring( Math.max(0, this.start-CONTEXT_TOKEN_COUNT), Math.min(this.end+CONTEXT_TOKEN_COUNT, start.getContext().getEnd())-1); } this.context = context; } /**
@Override public boolean evaluate(Object span) { return types.contains(((Span)span).getType()); } });
/** * Getter for token text * @return the text of the token */ public String getTokenText(){ return token.getSpan(); } /**
/** * Getter for the end character position of the text * @return the end character position */ public int getEndChar(){ return chunk.getEnd(); } /**
/** * Getter for the start character position * @return the start character position of the selected text span. */ public int getStartChar(){ return chunk.getStart(); } /**
@Override public boolean evaluate(Object span) { return types.contains(((Span)span).getType()); } });