Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using pre-trained MaltParser model with NLTK

Can anyone tell me how to use a pre-trained MaltParser model (http://maltparser.org/mco/english_parser/engmalt.html) in nltk.parse.malt? The only option seems to be to train from a file (If anyone could point me in the direction of a good, publicly available training file, that would be great, too).

like image 415
user1172502 Avatar asked Oct 09 '22 21:10

user1172502


1 Answers

The MaltParser interface in older versions of NLTK used to hardcode the path to the model. This was fixed in commit e9e443. You can now do the following:

maltparser = MaltParser(mco="/path/to/your/model.mco")

As of this writing, easy_install and pip still install a version of NLTK that doesn't include this fix (2.0.1rc4). If you cannot afford switching to a bleeding edge version, you could use the following hack:

maltparser = MaltParser()
maltparser.mco = "/path/to/your/model.mco"

Pre-trained models can be found on MaltParser's official website.

like image 90
pflaquerre Avatar answered Oct 12 '22 11:10

pflaquerre