本文介绍了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?


推荐答案

您的工作目录未正确设置。 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:

安装NLTK:

要使用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),可以从这里下载:

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):

哪些仍然位于/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投掷课没有发现异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 07:50