![]() List spans = Arrays.asList(nameFinderME.find(tokens)) NameFinderME nameFinderME = new NameFinderME(model) TokenNameFinderModel model = new TokenNameFinderModel( getResourceAsStream("/models/en-ner-person.bin") InputStream inputStreamNameFinder = getClass() SimpleTokenizer tokenizer = SimpleTokenizer.INSTANCE GivenEnglishPersonModel_whenNER_thenPersonsAreDetected() Then we can use the find() method to find named entities in a given text: void We need to load the model using TokenNameFinderModel and pass it into an instance of NameFinderME. OpenNLP uses pre-defined models for person names, date and time, locations, and organizations. Note: the suffix “ME” is used in many class names in Apache OpenNLP and represents an algorithm that is based on “Maximum Entropy”. "Now is an abstract word for time, that is always flying.", ![]() SentenceDetectorME sdetector = new SentenceDetectorME(model) SentenceModel model = new SentenceModel(is) InputStream is = getClass().getResourceAsStream("/models/en-sent.bin") Then, we simply pass a text into the sentDetect() method to split it at the sentence boundaries: void givenEnglishModel_whenDetect_thenSentencesAreDetected() ![]() To implement sentence detection, we load the model and pass it into an instance of SentenceDetectorME. ![]()
0 Comments
Leave a Reply. |