问题
I have trained an OpenNLP Name Entity Recognizer. When I use it over some data it gives an output like:
[0..1) location
I rather want to output the original name that occurred in the data.
回答1:
this is a Span objects toString() output. Each call to find(String[]) can return multiple Spans, hence the find() method returns Span[]. Use this code to get the actual named entities
//"tokens" here is the String[] of words in your sentence
Span[] find = nf.find(tokens);
//use the Span's static method to get the String[] of names
String[] namedEntities = Span.spansToStrings(find, tokens);
A span is simply a start and end index to your String[] tokens.
来源:https://stackoverflow.com/questions/20495522/opennlp-name-entity-recognizer-output