Dependency Parsing using MaltParser and NLTK

2019-07-21 01:35发布

问题:

Consider the sentence

new_sent = '''PeterParker loves MaryJane.'''

I'm trying to parse this sentence by using malparser and NLTK as follows:

maltParser = nltk.parse.malt.MaltParser(working_dir="/Applications/maltparser-1.7.2", 
                                        mco="engmalt.linear-1.7",
                                        additional_java_args=['-Xmx1024m'])
graph = maltParser.raw_parse(new_sent)
print(graph.tree().pprint())

The result is

(. PeterParker loves MaryJane)

but the correct answer should be:

(loves PeterParker MaryJane .)

Is there something that I'm doing wrong here? Does anyone could help me?