private List<Section> detectSentences(AnalysedText at, String language) { SentenceDetector sentenceDetector = getSentenceDetector(language); List<Section> sentences; if(sentenceDetector != null){ sentences = new ArrayList<Section>(); for(opennlp.tools.util.Span sentSpan : sentenceDetector.sentPosDetect(at.getSpan())) { Sentence sentence = at.addSentence(sentSpan.getStart(), sentSpan.getEnd()); log.trace(" > add {}",sentence); sentences.add(sentence); } } else { sentences = null; } return sentences; }
return; case Sentence: span = at.addSentence(spanPos[0], spanPos[1]); break; case Chunk:
return; case Sentence: span = at.addSentence(spanPos[0], spanPos[1]); break; case Chunk:
while(sentences.incrementToken()){ OffsetAttribute offset = sentences.addAttribute(OffsetAttribute.class); Sentence s = at.addSentence(offset.startOffset(), offset.endOffset()); if(log.isTraceEnabled()) { log.trace("detected {}:{}",s,s.getSpan());
for(opennlp.tools.util.Span sentSpan : sentenceDetector.sentPosDetect(at.getSpan())) { Sentence sentence = at.addSentence(sentSpan.getStart(), sentSpan.getEnd()); log.trace(" > add {}",sentence);
while(sentences.incrementToken()){ OffsetAttribute offset = sentences.addAttribute(OffsetAttribute.class); Sentence s = at.addSentence(offset.startOffset(), offset.endOffset()); if(log.isTraceEnabled()) { log.trace("detected {}:{}",s,s.getSpan());
Sentence sent = at.addSentence(sentStartOffset, offset.startOffset()); lastSent = at.addSentence(sentStartOffset, offset.endOffset());