class nltk.parse.MaltParser(parser_dirname, model_filename=None, tagger=None, additional_java_args=None)[source]

A class for dependency parsing with MaltParser. The input is the paths to: - a maltparser directory - (optionally) the path to a pre-trained MaltParser .mco model file - (optionally) the tagger to use for POS tagging before parsing - (optionally) additional Java arguments

>>> from nltk.parse import malt
>>> # With MALT_PARSER and MALT_MODEL environment set.
>>> mp = malt.MaltParser('maltparser-1.7.2', 'engmalt.linear-1.7.mco') 
>>> mp.parse_one('I shot an elephant in my pajamas .'.split()).tree() 
(shot I (elephant an) (in (pajamas my)) .)
>>> # Without MALT_PARSER and MALT_MODEL environment.
>>> mp = malt.MaltParser('/home/user/maltparser-1.7.2/', '/home/user/engmalt.linear-1.7.mco') 
>>> mp.parse_one('I shot an elephant in my pajamas .'.split()).tree() 
(shot I (elephant an) (in (pajamas my)) .)


__init__(parser_dirname[, model_filename, ...]) An interface for parsing with the Malt Parser.
generate_malt_command(inputfilename[, ...]) This function generates the maltparser command use at the terminal.
return:The grammar used by this parser.
parse(sent, *args, **kwargs)
return:An iterator that generates parse trees for the sentence.
parse_all(sent, *args, **kwargs)
parse_one(sent, *args, **kwargs)
rtype:Tree or None
parse_sents(sentences[, verbose, ...]) Use MaltParser to parse multiple sentences.
parse_tagged_sents(sentences[, verbose, ...]) Use MaltParser to parse multiple POS tagged sentences.
train(depgraphs[, verbose]) Train MaltParser from a list of DependencyGraph objects
train_from_file(conll_file[, verbose]) Train MaltParser from a file