Example usage for opennlp.tools.namefind NameFinderME probs

List of usage examples for opennlp.tools.namefind NameFinderME probs

Introduction

In this page you can find the example usage for opennlp.tools.namefind NameFinderME probs.

Prototype

public double[] probs(Span[] spans) 

Source Link

Document

Returns an array of probabilities for each of the specified spans which is the arithmetic mean of the probabilities for each of the outcomes which make up the span.

Usage

From source file:org.sglover.nlp.CoreNLPEntityTagger.java

private void findEntities(Entities namedEntities, List<TextAnnotation> allTextAnnotations, String[] tokens) {
    for (Map.Entry<String, TokenNameFinderModel> finderEntry : tokenNameFinders.entrySet()) {
        String type = finderEntry.getKey();
        NameFinderME finder = new NameFinderME(finderEntry.getValue());
        try {/*from   w ww.j  a  v a2  s  .c o m*/
            Span[] spans = finder.find(tokens);
            double[] probs = finder.probs(spans);

            for (int ni = 0; ni < spans.length; ni++) {
                allTextAnnotations.add(new TextAnnotation(type, spans[ni], probs[ni]));
            }
        } finally {
            finder.clearAdaptiveData();
        }
    }

    if (allTextAnnotations.size() > 0) {
        removeConflicts(allTextAnnotations);
    }

    convertTextAnnotationsToNamedEntities(tokens, allTextAnnotations, namedEntities);
}