@Produces(MediaType.APPLICATION_JSON) public Map<String, NameAnn> findNames(@QueryParam("model") String modelName, String text) { Span[] sentenceSpans = sentDetect.sentPosDetect(text); Map<String, NameAnn> map = new HashMap<>();
for (Span sentence : sentDetector.sentPosDetect(sample.getText())) { Span conflictingName = coveredIndexes.get(sentence.getStart());
@Override protected SentenceSample processSample(SentenceSample sample) { Span[] predictions = trimSpans(sample.getDocument(), sentenceDetector.sentPosDetect(sample.getDocument())); Span[] references = trimSpans(sample.getDocument(), sample.getSentences()); fmeasure.updateScores(references, predictions); return new SentenceSample(sample.getDocument(), predictions); }
public void fillSentences() throws IOException { char[] c = new char[256]; int sz = 0; StringBuilder b = new StringBuilder(); while ((sz = input.read(c)) >= 0) { b.append(c, 0, sz); } String tmp = b.toString(); inputSentence = tmp.toCharArray(); sentences = detector.sentPosDetect(tmp); tokenOffset = 0; }
@Override public List<RawSentence> tokenize( final String sentenceSource ) { if ( Strings.isNullOrEmpty(sentenceSource) ) { return Collections.emptyList(); } final Span[] sentencesStrings = sentenceTokenizer.get().sentPosDetect(sentenceSource); return Arrays.stream(sentencesStrings) .map(span -> new RawSentence(span.getCoveredText(sentenceSource).toString(), span.getStart(), span.getEnd())) .collect(Collectors.toList()); } }
private TextAnalysisIterator(String text,String language){ this.text = text; this.language = language; if(text == null || text.isEmpty()){ sentenceSpans = new Span[]{}; } else { SentenceDetector sd = getSentenceDetector(); if(sd != null){ sentenceSpans = sd.sentPosDetect(text); } else { sentenceSpans = new Span[]{new Span(0, text.length())}; } } } @Override
private TextAnalysisIterator(String text,String language){ this.text = text; this.language = language; if(text == null || text.isEmpty()){ sentenceSpans = new Span[]{}; } else { SentenceDetector sd = getSentenceDetector(); if(sd != null){ sentenceSpans = sd.sentPosDetect(text); } else { sentenceSpans = new Span[]{new Span(0, text.length())}; } } } @Override
/** * Method tokenize input to list of sentence. It also append * * @param sentenceSource * * @return List of found sentences * * @throws IOException */ public List<RawSentence> tokenize(final Reader sentenceSource ) throws IOException { final StringBuilder textBuilder = new StringBuilder(textBufferSize); final char[] buffer = new char[readBufferSize]; int read; do { read = sentenceSource.read(buffer); if ( read == -1 ) { break; } textBuilder.append(buffer, 0, read); } while ( true ); final String text = textBuilder.toString(); final Span[] sentencesStrings = sentenceTokenizer.get().sentPosDetect(text); return Arrays.stream(sentencesStrings) .map(span -> new RawSentence(span.getCoveredText(text).toString(), span.getStart(), span.getEnd())) .collect(Collectors.toList()); }
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; }
public List<SentenceExtraction> extract(String text) { Span[] spans = this.sentenceDetector.sentPosDetect(text); List<SentenceExtraction> parsedSentences = new ArrayList<SentenceExtraction>(spans.length); for (Span span : spans) { String string = text.substring(span.getStart(), span.getEnd()).trim(); if (validate(string)) { string = clean(string); parsedSentences.add(new SentenceExtraction(string, Range.fromInterval(span.getStart(), span.getEnd()))); } } return parsedSentences; }
@Produces(MediaType.APPLICATION_JSON) public Map<String, NameAnn> findNames(@QueryParam("model") String modelName, String text) { Span[] sentenceSpans = sentDetect.sentPosDetect(text); Map<String, NameAnn> map = new HashMap<>();
sentenceSpans[0] = new Span(0,line.length()) ; } else { sentenceSpans = _sentenceDetector.sentPosDetect(line) ;
SentenceDetector sentenceDetector = getSentenceDetector(language); if(sentenceDetector != null){ for(opennlp.tools.util.Span sentSpan : sentenceDetector.sentPosDetect(at.getSpan())) {
for (Span sentence : sentDetector.sentPosDetect(sample.getText())) { Span conflictingName = coveredIndexes.get(sentence.getStart());
for (Span sentence : sentDetector.sentPosDetect(sample.getText())) { Span conflictingName = coveredIndexes.get(sentence.getStart());
@Override protected SentenceSample processSample(SentenceSample sample) { Span[] predictions = trimSpans(sample.getDocument(), sentenceDetector.sentPosDetect(sample.getDocument())); Span[] references = trimSpans(sample.getDocument(), sample.getSentences()); fmeasure.updateScores(references, predictions); return new SentenceSample(sample.getDocument(), predictions); }
@Override protected SentenceSample processSample(SentenceSample sample) { Span[] predictions = trimSpans(sample.getDocument(), sentenceDetector.sentPosDetect(sample.getDocument())); Span[] references = trimSpans(sample.getDocument(), sample.getSentences()); fmeasure.updateScores(references, predictions); return new SentenceSample(sample.getDocument(), predictions); }