In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to use Name Finder of OpenNLP". In daily operation, I believe many people have doubts about how to use Name Finder of OpenNLP. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to use Name Finder of OpenNLP". Next, please follow the editor to study!
# # Named Entity Recognition Command entity recognition # # Name Finder can detect named entities and numbers in text. To detect entities, Name Finder needs a model. The model depends on the language and entity types it trains. OpenNlP provides many pre-trained name finder models, which are trained using a variety of corpus available for free. They can be downloaded from our model download page. Names is found in unprocessed (raw) text, which must be split into tokens and Sentences. Detailed descriptions are given in getting started with Sentence detector and tokenizer. Make sure that the tokenization data used for training is the same as the input text.
# Name Finder Tool### Name Finder API### uses Name Finder in a production system, and it is highly recommended to embed it directly into the application instead of using the command line interface. First, the name finder model must be loaded from disk or other source. The following example is actually loaded on disk.
InputStream modelIn = new FileInputStream ("en-ner-person.bin"); try {TokenNameFinderModel model = new TokenNameFinderModel (modelIn);} catch (IOException e) {e.printStackTrace ();} finally {if (modelIn! = null) {try {modelIn.close ();} catch (IOException e) {}
There are many reasons why model loading fails:
The basic Icano problem
The version of the model is not compatible with the OpenNLP version
The model is loaded into the wrong component, for example, a tokenizer model is loaded into the TokenNameFinderModel class
Model content is not available for some other reason
NameFinderME can be instantiated after the model is loaded.
NameFinderME nameFinder = new NameFinderME (model)
Initialization is now complete and Name Finder is now available. NameFinderME is not thread-safe, it must be called in only one thread. To use multi-threading and multi-NameFinderME instance sharing, you can create the same model instance. Input text must be sliced into documents,sentences, and tokens. The application calls the find method to perform entity detection in each sentence in the document. After every document clearAdaptiveData must be called to clear the adaptive data in the feature generators.Not calling clearAdaptiveData can lead to a sharp drop in the detection rate after a few documents. The following code explains this:
For (String document [] []: documents) {for (String [] sentence: document) {Span nameSpans [] = nameFinder.find (sentence); / / do something with the names} nameFinder.clearAdaptiveData ()}
The following snippet shows a call to find:
String sentence [] = new String [] {"Pierre", "Vinken", "is", "61", "years"old", "."}; Span nameSpans [] = nameFinder.find (sentence). At this point, the study on "how to use the Name Finder of OpenNLP" is over. I hope to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.