Java Reference
In-Depth Information
System.out.println("Entity: "
+ tokens[nameSpans[i].getStart()]);
}
System.out.println();
}
The output is as follows. There is an extra blank line between the two people detected be-
cause the second sentence did not contain a person:
Span: [0..1) person
Entity: Joe
Span: [7..9) person
Entity: Fred
Span: [0..1) person
Entity: Joe
Span: [19..20) person
Entity: Sally
Span: [26..27) person
Entity: Fred
Determining the accuracy of the entity
When the TokenNameFinderModel identifies entities in text, it computes a probabil-
ity for that entity. We can access this information using the probs method as shown in
the following line of code. This method returns an array of doubles, which corresponds to
the elements of the nameSpans array:
double[] spanProbs = nameFinder.probs(nameSpans);
Add this statement to the previous example immediately after the use of the find meth-
od. Then add the next statement at the end of the nested for statement:
System.out.println("Probability: " + spanProbs[i]);
When the example is executed, you will get the following output. The probability fields
reflect the confidence level of the entity assignment. For the first entity, the model is
80.529 percent confident that "Joe" is a person:
Search WWH ::




Custom Search