简体   繁体   English

将Stanford POS标记器实现为.jar的Java应用程序无法运行,在NetBeans IDE中运行良好

[英]Trouble running Java application implementing Stanford POS tagger as a .jar, runs fine in NetBeans IDE

I am trying to implement Stanford's POS tagger in a Java application using the following lines of code: 我正在尝试使用以下代码行在Java应用程序中实现Stanford的POS标记器:

             MaxentTagger tagger = new MaxentTagger("taggers/english-left3words-distsim.tagger");
             String taggedString = tagger.tagString(string);

It works fine when running the project in NetBeans, but the executable .jar compiled in NetBeans will not run the tagger. 在NetBeans中运行项目时,它工作正常,但是在NetBeans中编译的可执行文件.jar将不会运行标记器。 I am fairly new to Java and to programming in general, and I haven't figured out how to log whatever error/exception is occurring in the GUI console of the application, and no error/exception occurs when running the project in NetBeans. 我对Java和一般程序设计还很陌生,并且我还没有弄清楚如何记录应用程序的GUI控制台中发生的任何错误/异常,并且在NetBeans中运行项目时也没有错误/异常发生。

A couple things occurred to me that could be happening. 我发生了可能会发生的几件事。 The Stanford NLP group says: 斯坦福大学自然语言处理小组说:

"The system requires Java 1.8+ to be installed. Depending on whether you're running 32 or 64 bit Java and the complexity of the tagger model, you'll need somewhere between 60 and 200 MB of memory to run a trained tagger (ie, you may need to give java an option like java -mx200m). Plenty of memory is needed to train a tagger. It again depends on the complexity of the model but at least 1GB is usually needed, often more." “系统需要安装Java 1.8+。根据运行的是32位Java还是64位Java,以及标记器模型的复杂性,您将需要60到200 MB的内存来运行经过训练的标记器(即,您可能需要为java提供一个类似java -mx200m的选项。训练标记器需要大量内存。这又取决于模型的复杂性,但通常至少需要1GB,甚至更多。 http://nlp.stanford.edu/software/tagger.shtml http://nlp.stanford.edu/software/tagger.shtml

In the shortcut that I use to run the application, I specified the path of a javaw.exe that is version 1.8+, and I also tried replacing the latest release of the tagger with the August 2014 release, pre-Java 8 upgrade, and neither solved the problem. 在用于运行该应用程序的快捷方式中,我指定了版本为1.8+的javaw.exe的路径,并且还尝试用2014年8月发行的版本,最新的Java 8升级以及都没有解决问题。

As for the memory issue, I went to my Java control panel and entered "-Xms1024m" as a runtime parameter for every javaw.exe on my machine, and that also did not solve the problem. 至于内存问题,我进入了Java控制面板,并为机器上的每个javaw.exe输入了“ -Xms1024m”作为运行时参数,但这也不能解决问题。

Can anybody suggest what might be making the .jar fail to run the tagger, when it works fine running the project from NetBeans? 在NetBeans中正常运行项目时,是否有人建议.jar无法运行标记器?

Thanks! 谢谢!

peeskillet that worked, thanks (great name by the way)! peeskillet有效,谢谢(顺便说一句大名)! Specifically, in the projects tab I right-clicked "Source Packages" > "New" > "Java Package," called the new package "taggers," and moved the .tagger files into the "taggers" directory under the "src" directory under the project root directory. 具体来说,在项目选项卡中,我右键单击“源包”>“新建”>“ Java包”,将其称为新包“ taggers”,然后将.tagger文件移动到“ src”目录下的“ taggers”目录中在项目根目录下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM