English 中文(简体)
OpenNLP - Environment
  • 时间:2024-12-22

OpenNLP - Environment


Previous Page Next Page  

In this chapter, we will discuss how you can setup OpenNLP environment in your system. Let’s start with the installation process.

Instalpng OpenNLP

Following are the steps to download Apache OpenNLP pbrary in your system.

Step 1 − Open the homepage of Apache OpenNLP by cpcking the following pnk − https://opennlp.apache.org/.

Apache OpenNLP

Step 2 − Now, cpck on the Downloads pnk. On cpcking, you will be directed to a page where you can find various mirrors which will redirect you to the Apache Software Foundation Distribution directory.

Step 3 − In this page you can find pnks to download various Apache distributions. Browse through them and find the OpenNLP distribution and cpck it.

Distribution

Step 4 − On cpcking, you will be redirected to the directory where you can see the index of the OpenNLP distribution, as shown below.

Index of Opennlp

Cpck on the latest version from the available distributions.

Step 5 − Each distribution provides Source and Binary files of OpenNLP pbrary in various formats. Download the source and binary files, apache-opennlp-1.6.0-bin.zip and apache-opennlp1.6.0-src.zip (for Windows).

Source and Binary Files of OpenNLP

Setting the Classpath

After downloading the OpenNLP pbrary, you need to set its path to the bin directory. Assume that you have downloaded the OpenNLP pbrary to the E drive of your system.

Now, follow the steps that are given below −

Step 1 − Right-cpck on My Computer and select Properties .

Step 2 − Cpck on the Environment Variables button under the Advanced tab.

Step 3 − Select the path variable and cpck the Edit button, as shown in the following screenshot.

System Variables Path

Step 4 − In the Edit Environment Variable window, cpck the New button and add the path for OpenNLP directory E:apache-opennlp-1.6.0in and cpck the OK button, as shown in the following screenshot.

Edit Environment Variable Window

Ecppse Installation

You can set the Ecppse environment for OpenNLP pbrary, either by setting the Build path to the JAR files or by using pom.xml.

Setting Build Path to the JAR Files

Follow the steps given below to install OpenNLP in Ecppse −

Step 1 − Make sure that you have Ecppse environment installed in your system.

Step 2 − Open Ecppse. Cpck File → New → Open a new project, as shown below.

New Project

Step 3 − You will get the New Project wizard. In this wizard, select Java project and proceed by cpcking the Next button.

Java Project

Step 4 − Next, you will get the New Java Project wizard. Here, you need to create a new project and cpck the Next button, as shown below.

My Project

Step 5 − After creating a new project, right-cpck on it, select Build Path and cpck Configure Build Path.

Configure Build Path

Step 6 − Next, you will get the Java Build Path wizard. Here, cpck the Add External JARs button, as shown below.

Java Build Path

Step 7 − Select the jar files opennlp-tools-1.6.0.jar and opennlp-uima-1.6.0.jar located in the pb folder of apache-opennlp-1.6.0 folder.

Opennlp Tools

On cpcking the Open button in the above screen, the selected files will be added to your pbrary.

Add External JARs

On cpcking OK, you will successfully add the required JAR files to the current project and you can verify these added pbraries by expanding the Referenced Libraries, as shown below.

Sample Workspace

Using pom.xml

Convert the project into a Maven project and add the following code to its pom.xml.

<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
   <modelVersion>4.0.0</modelVersion> 
   <groupId>myproject</groupId> 
   <artifactId>myproject</artifactId> 
   <version>0.0.1-SNAPSHOT</version> 
   <build> 
      <sourceDirectory>src</sourceDirectory> 
      <plugins> 
         <plugin> 
            <artifactId>maven-compiler-plugin</artifactId> 
            <version>3.5.1</version> 
            <configuration> 
               <source>1.8</source> 
               <target>1.8</target> 
            </configuration> 
         </plugin> 
      </plugins> 
   </build> 
   <dependencies>  
      <dependency> 
         <groupId>org.apache.opennlp</groupId> 
         <artifactId>opennlp-tools</artifactId> 
         <version>1.6.0</version> 
     </dependency> 
     <dependency> 
         <groupId>org.apache.opennlp</groupId> 
         <artifactId>opennlp-uima</artifactId> 
         <version>1.6.0</version> 
      </dependency>      
  </dependencies>  
</project> 
Advertisements