class MaltParser(ParserI): (source)
Constructor: MaltParser(parser_dirname, model_filename, tagger, additional_java_args)
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
- Example:
 >>> 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') # doctest: +SKIP >>> mp.parse_one('I shot an elephant in my pajamas .'.split()).tree() # doctest: +SKIP (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') # doctest: +SKIP >>> mp.parse_one('I shot an elephant in my pajamas .'.split()).tree() # doctest: +SKIP (shot I (elephant an) (in (pajamas my)) .)
| Method | __init__ | 
    An interface for parsing with the Malt Parser. | 
| Method | generate | 
    This function generates the maltparser command use at the terminal. | 
| Method | parse | 
    Use MaltParser to parse multiple sentences. Takes a list of sentences, where each sentence is a list of words. Each sentence will be automatically tagged with this MaltParser instance's tagger. | 
| Method | parse | 
    Use MaltParser to parse multiple POS tagged sentences. Takes multiple sentences where each sentence is a list of (word, tag) tuples. The sentences must have already been tokenized and tagged. | 
| Method | train | 
    Train MaltParser from a list of DependencyGraph objects | 
| Method | train | 
    Train MaltParser from a file :param conll_file: str for the filename of the training input data :type conll_file: str | 
| Instance Variable | additional | 
    Undocumented | 
| Instance Variable | malt | 
    Undocumented | 
| Instance Variable | model | 
    Undocumented | 
| Instance Variable | tagger | 
    Undocumented | 
| Instance Variable | working | 
    Undocumented | 
| Static Method | _execute | 
    Undocumented | 
| Instance Variable | _trained | 
    Undocumented | 
              Inherited from ParserI:
            
| Method | grammar | 
    No summary | 
| Method | parse | 
    When possible this list is sorted from most likely to least likely. | 
| Method | parse | 
    No summary | 
| Method | parse | 
    No summary | 
An interface for parsing with the Malt Parser.
contains the maltparser-1.x.jar
:type parser_dirname: str
:param model_filename: The name of the pre-trained model with .mco file
extension. If provided, training will not be required.
(see http://www.maltparser.org/mco/mco.html and
see http://www.patful.com/chalk/node/185)
:type model_filename: str
:param tagger: The tagger used to POS tag the raw string before
formatting to CONLL format. It should behave like nltk.pos_tag
:type tagger: function
:param additional_java_args: This is the additional Java arguments that
one can use when calling Maltparser, usually this is the heapsize
limits, e.g. additional_java_args=['-Xmx1024m']
(see http://goo.gl/mpDBvQ)
:type additional_java_args: list
| Parameters | |
| parser | The path to the maltparser directory that | 
| model | Undocumented | 
| tagger | Undocumented | 
| additional | Undocumented | 
This function generates the maltparser command use at the terminal.
| Parameters | |
| inputfilename:str | path to the input file | 
| outputfilename:str | path to the output file | 
| mode | Undocumented | 
nltk.parse.api.ParserI.parse_sentsUse MaltParser to parse multiple sentences. Takes a list of sentences, where each sentence is a list of words. Each sentence will be automatically tagged with this MaltParser instance's tagger.
| Parameters | |
| sentences | Input sentences to parse | 
| verbose | Undocumented | 
| top | Undocumented | 
| sentence:list(list(str)) | Undocumented | 
| Returns | |
| iter(DependencyGraph) | |
Use MaltParser to parse multiple POS tagged sentences. Takes multiple sentences where each sentence is a list of (word, tag) tuples. The sentences must have already been tokenized and tagged.
representation of each sentence
| Parameters | |
| sentences | Input sentences to parse | 
| verbose | Undocumented | 
| top | Undocumented | 
| sentence:list(list(tuple(str, str))) | Undocumented | 
| Returns | |
| iter(iter(DependencyGraph)) the dependency graph | |
Train MaltParser from a list of DependencyGraph objects
| Parameters | |
| depgraphs:DependencyGraph | list of DependencyGraph objects for training input data | 
| verbose | Undocumented |