Skip to content

Commit

Permalink
added MaltParser param for additional Java args to allow larger heap
Browse files Browse the repository at this point in the history
  • Loading branch information
dhgarrette committed Dec 28, 2012
1 parent 2d41e81 commit f63cdcc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions nltk/parse/malt.py
Expand Up @@ -23,7 +23,7 @@

class MaltParser(ParserI):

def __init__(self, tagger=None, mco=None, working_dir=None):
def __init__(self, tagger=None, mco=None, working_dir=None, additional_java_args=None):
"""
An interface for parsing with the Malt Parser.
Expand All @@ -36,6 +36,7 @@ def __init__(self, tagger=None, mco=None, working_dir=None):
self.mco = 'malt_temp' if mco is None else mco
self.working_dir = tempfile.gettempdir() if working_dir is None\
else working_dir
self.additional_java_args = [] if additional_java_args is None else additional_java_args
self._trained = mco is not None

if tagger is not None:
Expand Down Expand Up @@ -141,7 +142,8 @@ def tagged_parse(self, sentence, verbose=False):
input_file.write('\n')
input_file.close()

cmd = ['java', '-jar', self._malt_bin, '-w', self.working_dir,
cmd = ['java'] + self.additional_java_args + ['-jar', self._malt_bin,
'-w', self.working_dir,
'-c', self.mco, '-i', input_file.name,
'-o', output_file.name, '-m', 'parse']

Expand Down

0 comments on commit f63cdcc

Please sign in to comment.