我对斯坦福大学的 coreNLP 非常陌生,我正在尝试通过创建模型来训练它。我有一个包含 dev.txt、train.txt 和 test.txt 的文件夹以及一个名为 stanford-corenlp-3.5.1-models.jar 的 jar 文件。根据this问题,我可以通过在终端中执行以下命令来创建模型:
java -mx8g edu.stanford.nlp.sentiment.SentimentTraining -numHid 25 -trainPath train.txt -devPath dev.txt -train -model model.ser.gz
但是,当我在终端中运行它时,出现以下错误:
Error: could not find or load main class edu.stanford.nlp.sentiment.SentimentTraining
有人可以提供如何训练 CoreNLP 的分步说明吗?我去了斯坦福website看看训练是如何进行的,但我仍然很困惑。我认为创建一个模型(例如 model.ser.gz)所需的只是这三个文本文件和一个 jar 文件。
非常感谢任何帮助,谢谢!
最佳答案
您需要将 CoreNLP jar 文件包含在类路径中。因此,您的 java 命令应如下所示:
java -cp/path/to/corenlp/jar:/path/to/corenlp/library/dependencies -mx8g ...
从 CoreNLP 发行版的根目录中,您可以只包含目录中的所有 jar 文件;例如,
java -cp "*"-mx8g edu.stanford.nlp.sentiment.SentimentTraining -numHid 25 -trainPath train.txt -devPath dev.txt -train -model model.ser.gz
关于java - 如何通过训练创建Stanford coreNLP模型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33622132/