Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8341117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:22:30+00:00 2026-06-09T05:22:30+00:00

I am trying to use MaltParser from NLTK. I could get to the point

  • 0

I am trying to use MaltParser from NLTK.

I could get to the point of configuring the parser:

import nltk
parser = nltk.parse.malt.MaltParser()
parser.config_malt()
parser.train_from_file('malt_train.conll')

but when it comes to actual parsing, parser returns an error:

File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/nltk/parse/malt.py", line 98, in raw_parse
return self.parse(words, verbose)
File "/Library/Python/2.7/site-packages/nltk/parse/malt.py", line 85, in parse
return self.tagged_parse(taggedwords, verbose)
File "/Library/Python/2.7/site-packages/nltk/parse/malt.py", line 139, in tagged_parse
return DependencyGraph.load(output_file)
File "/Library/Python/2.7/site-packages/nltk/parse/dependencygraph.py", line 121, in    load
return DependencyGraph(open(file).read())
IOError: [Errno 2] No such file or directory:'/var/folders/77/ch5yxf153jl67kmqr5jqywgr0000gn/T/malt_output.conll'

Here is the command that gives the error (from malt.py):

['java', '-jar /usr/lib/malt-1.6.1/malt.jar', '-w /var/folders/77/ch5yxf153jl67kmqr5jqywgr0000gn/T', '-c malt_temp', '-i /var/folders/77/ch5yxf153jl67kmqr5jqywgr0000gn/T/malt_input.conll', '-o /var/folders/77/ch5yxf153jl67kmqr5jqywgr0000gn/T/malt_output.conll', '-m parse']

I tried running jus the java command and here is what I get:

 The file entry 'malt_temp_singlemalt.info' in the mco file '/var/folders/77/ch5yxf153jl67kmqr5jqywgr0000gn/T/malt_temp.mco' cannot be loaded.  

Also tried the same with the pre-trained engmalt.poly.mco and engmalt.linear.mco

Any suggestions are very welcome.

EDIT : Here is the full function from malt.py

def tagged_parse(self, sentence, verbose=False):
    """
    Use MaltParser to parse a sentence. Takes a sentence as a list of
    (word, tag) tuples; the sentence must have already been tokenized and
    tagged.

    @param sentence: Input sentence to parse
    @type sentence: L{list} of (word, tag) L{tuple}s.
    @return: C{DependencyGraph} the dependency graph representation of the sentence
    """

    if not self._malt_bin:
        raise Exception("MaltParser location is not configured.  Call config_malt() first.")
    if not self._trained:
        raise Exception("Parser has not been trained.  Call train() first.")

    input_file = os.path.join(tempfile.gettempdir(), 'malt_input.conll')
    output_file = os.path.join(tempfile.gettempdir(), 'malt_output.conll')

    execute_string = 'java -jar %s -w %s -c %s -i %s -o %s -m parse'
    if not verbose:
        execute_string += ' > ' + os.path.join(tempfile.gettempdir(), "malt.out")

    f = None
    try:
        f = open(input_file, 'w')

        for (i, (word,tag)) in enumerate(sentence):
            f.write('%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' % 
                    (i+1, word, '_', tag, tag, '_', '0', 'a', '_', '_'))
        f.write('\n')
        f.close()

        cmd = ['java', '-jar %s' % self._malt_bin, '-w %s' % tempfile.gettempdir(), 
               '-c %s' % self.mco, '-i %s' % input_file, '-o %s' % output_file, '-m parse']
        print cmd

        self._execute(cmd, 'parse', verbose)

        return DependencyGraph.load(output_file)
    finally:
        if f: f.close()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:22:31+00:00Added an answer on June 9, 2026 at 5:22 am

    Iam not sure if the Problem is still unsolved (but I think its already solved),
    but as I had the same problems a while ago, I would like to share my knowledge.

    First of all, the MaltParser-Jar does not accept a .connl file with a direct path to its file in front of it. Like seen above.
    Why it is so… I do not know.

    But you can easily fix it by changing the command line to something like this:

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

    Here now the directory of the .conll file is set using the -w parameter. Using this you can load any .conll file from any given folder.
    I also change from tempfile.gettempdir() to self.working_dir, because in the “original” NLTK Version, always the /tmp/ folder is set as working directory. Even if you initialise the Maltparser with another working directory.

    I hope this informations will help someone.

    Another thing,
    if you want to parse many sentences as once, but each individually and not depending on all other sentences, you have to add a blank line in the input.conll file, and start the numeration for each sentence again with 1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying use this code to get image resolution from file bool GetImageSizeEx(const char
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
Trying to use Powershell to script the removal of specific custom errors from an
I am trying use std::copy to copy from two different iterator. But during course
I'm trying use to selenium with firefox on CentOS from command line like this:
i'm trying use webview to load a image from sdcard i use this path
Trying to use an excpetion class which could provide location reference for XML parsing,
I am trying to use the pretrained parsing model for English of the MaltParser
I am trying use the django ORM to get a list by year of
I'm trying use jquery to remove a class from an element (not knowing ahead

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.