You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@opennlp.apache.org by Chris Albertson <al...@gmail.com> on 2013/12/22 11:32:21 UTC

My first openNLP "Hello World" program - easy question

I'm trying to learn the Eclipse IDE and openNLP at the same time and
have what must an easy question.

I downloaded the source distribution placed in on Eclispse's workspace
directory and ran "mvm clean install" and it looks like all went well
(see quote below)

Next I write what I think should be an easy demo that starts like this:

public static void main(String[] args) throws IOException {
    POSModel model =  new POSModelLoader().load(new File("en-pos-maxent.bin"));
    POSTaggerME tagger = new POSTaggerME(model);

Of course both POSModelLoader and POSTaggerME can not be resolved so I
try adding this at the start of the file

import opennlp.tools.cmdline.postag.POSModelLoader;
import opennlp.tools.postag.POSModel;
import opennlp.tools.postag.POSSample;
import opennlp.tools.postag.POSTaggerME;

And now Eclipse tells me that opennlp.tools can not be resolved.  How
do I tell Eclipse where to look?  I figure Eclipse must have a search
path.

The openNLP distribution  is at
~/Documents/workspace/apache-opennlp-1.5.3/  If I cd to that location
and do "ls" here is what I get:

Chris Albertson's iMac:apache-opennlp-1.5.3 chris$ ls
LICENSE   docs   opennlp-docs
NOTICE    issuesFixed   opennlp-maxent
README   lib   opennlp-tools
RELEASE_NOTES.html opennlp  opennlp-uima
bin opennlp-distr



Here is the result I got that makes me think it all built OK:

[INFO] Reactor Summary:
[INFO] Apache OpenNLP Reactor ............................ SUCCESS [17.192s]
[INFO] Apache OpenNLP Maxent ............................. SUCCESS [26.876s]
[INFO] Apache OpenNLP Tools .............................. SUCCESS [58.494s]
[INFO] Apache OpenNLP UIMA Annotators .................... SUCCESS [8.633s]
[INFO] Apache OpenNLP Documentation ...................... SUCCESS [13.155s]
[INFO] Apache OpenNLP Distribution ....................... SUCCESS [13.131s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:22.351s


If it matters this is the machine/environment I'd running this on

mvn --version
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a;
2013-09-17 08:22:22-0700)
Maven home: /usr/local/apache-maven/apache-maven-3.1.1
Java version: 1.7.0_21, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9.1", arch: "x86_64", family: "mac"











-- 

Chris Albertson
Redondo Beach, California

Re: My first openNLP "Hello World" program - easy question

Posted by Richard Eckart de Castilho <re...@apache.org>.
I suggest you use Maven in Eclipse.

Make sure you have m2e (the Maven integration for Eclipse) installed.
Remove the checked-out projects from OpenNLP from your workspace 
(do not tick the "delete from disk"). Use Import -> Existing Maven Projects
and point it to the place where you checked out OpenNLP to. This should
reimport the projects, this time as proper Maven projects.

When you create your own hello-world project, also create it as a Maven
project and add the opennlp projects you required as dependencies in the
Maven POM editor.

With m2e, there should be no need to run Maven on the command line at all.
Recent version of Eclipse (e.g. 4.3.x) may already come with m2e preinstalled.

Cheers,

-- Richard

On 22.12.2013, at 08:32, Chris Albertson <al...@gmail.com> wrote:

> I'm trying to learn the Eclipse IDE and openNLP at the same time and
> have what must an easy question.
> 
> I downloaded the source distribution placed in on Eclispse's workspace
> directory and ran "mvm clean install" and it looks like all went well
> (see quote below)
> 
> Next I write what I think should be an easy demo that starts like this:
> 
> public static void main(String[] args) throws IOException {
>    POSModel model =  new POSModelLoader().load(new File("en-pos-maxent.bin"));
>    POSTaggerME tagger = new POSTaggerME(model);
> 
> Of course both POSModelLoader and POSTaggerME can not be resolved so I
> try adding this at the start of the file
> 
> import opennlp.tools.cmdline.postag.POSModelLoader;
> import opennlp.tools.postag.POSModel;
> import opennlp.tools.postag.POSSample;
> import opennlp.tools.postag.POSTaggerME;
> 
> And now Eclipse tells me that opennlp.tools can not be resolved.  How
> do I tell Eclipse where to look?  I figure Eclipse must have a search
> path.
> 
> The openNLP distribution  is at
> ~/Documents/workspace/apache-opennlp-1.5.3/  If I cd to that location
> and do "ls" here is what I get:
> 
> Chris Albertson's iMac:apache-opennlp-1.5.3 chris$ ls
> LICENSE   docs   opennlp-docs
> NOTICE    issuesFixed   opennlp-maxent
> README   lib   opennlp-tools
> RELEASE_NOTES.html opennlp  opennlp-uima
> bin opennlp-distr
> 
> 
> 
> Here is the result I got that makes me think it all built OK:
> 
> [INFO] Reactor Summary:
> [INFO] Apache OpenNLP Reactor ............................ SUCCESS [17.192s]
> [INFO] Apache OpenNLP Maxent ............................. SUCCESS [26.876s]
> [INFO] Apache OpenNLP Tools .............................. SUCCESS [58.494s]
> [INFO] Apache OpenNLP UIMA Annotators .................... SUCCESS [8.633s]
> [INFO] Apache OpenNLP Documentation ...................... SUCCESS [13.155s]
> [INFO] Apache OpenNLP Distribution ....................... SUCCESS [13.131s]
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 2:22.351s
> 
> 
> If it matters this is the machine/environment I'd running this on
> 
> mvn --version
> Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a;
> 2013-09-17 08:22:22-0700)
> Maven home: /usr/local/apache-maven/apache-maven-3.1.1
> Java version: 1.7.0_21, vendor: Oracle Corporation
> Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/jre
> Default locale: en_US, platform encoding: UTF-8
> OS name: "mac os x", version: "10.9.1", arch: "x86_64", family: "mac"