How to run MaltParser with NLTK under GNU/Linux

Thanks to this Stackoverflow post, I could get MaltParser running with NLTK under Linux.

The first thing you need to do is to upgrade NLTK to the latest version since previous versions had a bug that prevented it from running MaltParser. NLTK can be upgraded with the command

pip install -U nltk

Next step is to download MaltParser.

Use pre trained mco file

Thats it.

The following programs explains the working.

from nltk.parse.malt import MaltParser
mp = MaltParser("/other/apps/maltparser-1.8.1","engmalt.poly-1.7.mco")
sent1 = 'What is your name'.split()
print(mp.parse_one(sent1).tree())

For the function MaltParser the arguments are the path to the downloaded MaltParser and the download mco file.

This will give you the output

(is What (name your))

Comments !