How to get opennlp plugin for pycharm

61 Views Asked by At

I have converted java codes to python but some functionalities which can only be done through java are being used so opennlp package of java has to be used and i am not able to get any plugin in pycharm which would help me use opennlp

I didn't find any plugin or package to run opennlp in pycharm

1

There are 1 best solutions below

0
Marslinho On

Like described here OpenNLP comes with a CLI. To use OpenNLP from Python you can simply read/write some data files from python and call the CLI manually from the shell (i would recommend using jupyter notebooks for a worklflow like: Python(write) -> OpenNLP-CLI (read/write) -> Python(read)-> ... ).

A basic command to communicate by files has the following syntax:

opennlp ToolName lang-model-name.bin < input.txt > output.txt

where lang-model-name.bin is the language model-file you need to download before (see step 3 below). Here you find a useful and short tutorial describing the basic usage of the CLI.

Alternatively, e.g. if you want to avoid a workflow like the described one, you can consider writing a basic wrapper API to the CLI with a tool like subprocess.


Setting up the CLI is very easy (like described in the docs):

  1. download binary and set %OPENNLP_HOME%\bin to Path
  2. install Java and setup %JAVA_HOME%
  3. You can download pre-defined models here