OpenNLP Name Entity Recognizer output

血红的双手。 提交于 2019-12-25 05:33:14

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!