Malt Parser投掷课没有发现异常 [英] Malt Parser throwing class not found exception

查看:166
本文介绍了Malt Parser投掷课没有发现异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图用NLTK中的Malt Parser解析句子。当我做 raw_parse(发送)时,它给出了退出代码1的错误。我在终端上执行了java命令,它给出了类找不到异常,我不明白什么是现在错了?

I'm trying to parse sentence with Malt Parser in NLTK. When I did raw_parse(sent) it gave an error with exit code 1. I executed java command on terminal and it gives class Not Found exception, I don't understand what is wrong now?


java -Xmx1024m -jar /usr/local/bin/malt.jar -w /home/abc/maltparser-1.7 .2 -c engmalt.linear-1.7 -i /home/abc/maltparser-1.7.2/malt_input.conllrPZgwc -o /home/abc/maltparser-1.7.2/malt_output.conllDMSKpg -m parse
Exception in threadmainjava.lang.NoClassDefFoundError:org / apache / log4j / Layout

java -Xmx1024m -jar /usr/local/bin/malt.jar -w /home/abc/maltparser-1.7.2 -c engmalt.linear-1.7 -i /home/abc/maltparser-1.7.2/malt_input.conllrPZgwc -o /home/abc/maltparser-1.7.2/malt_output.conllDMSKpg -m parse Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Layout


推荐答案

您的工作目录未正确设置。 Log4j是Malt Parser使用的包(参见:maltparser-1.7.2 / lib / log4j.jar)。其中用于逻辑记录。

Your working directory is not correctly set. Log4j is a package used by Malt Parser (see: maltparser-1.7.2/lib/log4j.jar). Which is used for logging logically.

为了在NLTK中运行maltparser,工作目录应设置为此文件夹(在您的情况下:/ home / abc / maltparser -1.7.2)。

In order to run maltparser in NLTK, the working directory should be set to this folder (in your case: /home/abc/maltparser-1.7.2).

因此,第一步是从git获取最新的NLTK:

So, step one is getting the latest NLTK from git:


git clone https://github.com/nltk/nltk.git

安装NLTK:


sudo python setup .py install

sudo python setup.py install

要使用NLTK运行Malt Parser,请尝试以下代码示例:

To run Malt Parser using NLTK try this code example:

import os
import nltk

os.environ['MALTPARSERHOME']="/home/abc/maltparser-1.7.2"
verbose = False
maltParser = nltk.parse.malt.MaltParser(working_dir="/home/abc/maltparser-1.7.2", 
    mco="engmalt.linear-1.7",
    additional_java_args=['-Xmx512m'])
print(maltParser.raw_parse('This is a test sentence', verbose=verbose).tree().pprint())

你可能会注意到我正在使用前-learned mco文件(engmalt.linear-1.7),可以从这里下载:
http://www.maltparser.org/mco/english_parser/engmalt.html

As you may notice I'm using the pre-learned mco file (engmalt.linear-1.7), which can be downloaded from here: http://www.maltparser.org/mco/english_parser/engmalt.html

将此mco文件移至:/ home / abc / maltparser -1.7.2目录。

Move this mco file to: /home/abc/maltparser-1.7.2 directory.

最后只有NLTK,但malt.jar除外。因此,创建一个副本(或重命名):

Finally NLTK only except malt.jar. So create a copy (or rename):


cp maltparser-1.7.2.jar malt.jar

cp maltparser-1.7.2.jar malt.jar

哪些仍然位于/home/abc/maltparser-1.7.2.jar目录中。

Which can still be located in your /home/abc/maltparser-1.7.2.jar directory.

希望你能让它运转起来!

Hopefully you'll get it running!

这篇关于Malt Parser投掷课没有发现异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆