OpenNLP - Command Line Interface


Advertisements

OpenNLP provides a Command Line Interface (CLI) to carry out different operations through the command line. In this chapter, we will take some examples to show how we can use the OpenNLP Command Line Interface.

Tokenizing

input.txt

Hi. How are you? Welcome to Howcodex. We provide free tutorials on various technologies

Syntax

 > opennlp TokenizerME path_for_models../en-token.bin <inputfile..> outputfile.. 

command

C:\> opennlp TokenizerME C:\OpenNLP_models/en-token.bin <input.txt >output.txt

output

Loading Tokenizer model ... done (0.207s)  
Average: 214.3 sent/s 
Total: 3 sent 
Runtime: 0.014s

output.txt

Hi . How are you ? Welcome to Howcodex . We provide free tutorials on various technologies

Sentence Detection

input.txt

Hi. How are you? Welcome to Howcodex. We provide free tutorials on various technologies

Syntax

 > opennlp SentenceDetector path_for_models../en-token.bin <inputfile..> outputfile.. 

command

C:\> opennlp SentenceDetector C:\OpenNLP_models/en-sent.bin <input.txt > output_sendet.txt 

Output

Loading Sentence Detector model ... done (0.067s)  

Average: 750.0 sent/s 
Total: 3 sent 
Runtime: 0.004s

Output_sendet.txt

Hi. How are you? 
Welcome to Howcodex. 
We provide free tutorials on various technologies 

Named Entity Recognition

input.txt

<START:person> <START:person> Mike <END> <END> is senior programming manager and 
<START:person> Rama <END> is a clerk both are working at Howcodex 

Syntax

 > opennlp TokenNameFinder path_for_models../en-token.bin <inputfile.. 

Command

C:\>opennlp TokenNameFinder C:\OpenNLP_models\en-ner-person.bin <input_namefinder.txt

Output

Loading Token Name Finder model ... done (0.730s) 
<START:person> <START:person> Mike <END> <END> is senior programming manager and 
<START:person> Rama <END> is a clerk both are working at Howcodex  
Average: 55.6 sent/s 
Total: 1 sent 
Runtime: 0.018s

Parts of Speech Tagging

Input.txt

Hi. How are you? Welcome to Howcodex. We provide free tutorials on various technologies 

Syntax

 > opennlp POSTagger path_for_models../en-token.bin <inputfile.. 

Command

C:\>opennlp POSTagger C:\OpenNLP_models/en-pos-maxent.bin < input.txt 

Output

Loading POS Tagger model ... done (1.315s) 
Hi._NNP How_WRB are_VBP you?_JJ Welcome_NNP to_TO Howcodex._NNP We_PRP 
provide_VBP free_JJ tutorials_NNS on_IN various_JJ technologies_NNS  

Average: 66.7 sent/s 
Total: 1 sent 
Runtime: 0.015s 
Advertisements