MaltParser working in python shell but not in a script:help warmly welcome

169 views
Skip to first unread message

Marco Ippolito

unread,
Apr 29, 2014, 4:00:14 PM4/29/14
to nltk-...@googlegroups.com
  • Hi everybody,

  • I would like to use MaltParser in conjunction with Nltk.

  • Bu it happens that the same code works in the python shell, but gives an error message if put in a script:

  • >>> import nltk >>> parser = nltk.parse.malt.MaltParser(working_dir="/home/ubuntu/maltparser-1.7.2", mco="engmalt.linear-1.7") >>> txt = "This is a test sentence" >>> graph = parser.raw_parse(txt) >>> graph.tree().pprint() '(This (sentence is a test))'

  • 19:48

    MaltPipeline.py: 

    • #!/usr/bin/python

    # Dependency Trees

    import nltk parser = nltk.parse.malt.MaltParser(working_dir="home/ubuntu/maltparser-1.7.2", mco="engmalt.linear-1.7")

    txt = "This a test sentence" graph = parser.raw_parse(txt) graph.tree().pprint()

  • 19:48
    python MaltPipeline.py

    Traceback (most recent call last): File "MaltPipeline.py", line 9, in <module> graph = parser.raw_parse(txt) File "/usr/local/lib/python2.7/dist-packages/nltk/parse/malt.py", line 111, in raw_parse return self.parse(words, verbose) File "/usr/local/lib/python2.7/dist-packages/nltk/parse/malt.py", line 98, in parse return self.tagged_parse(taggedwords, verbose) File "/usr/local/lib/python2.7/dist-packages/nltk/parse/malt.py", line 131, in tagged_parse delete=False) File "/usr/lib/python2.7/tempfile.py", line 454, in NamedTemporaryFile (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags) File "/usr/lib/python2.7/tempfile.py", line 235, in _mkstemp_inner fd = _os.open(file, flags, 0600) OSError: [Errno 2] No such file or directory: 'home/ubuntu/maltparser-1.7.2/malt_input.conllT4_r6M

Any help is warmly welcome.

Marco

Constantin Orăsan

unread,
Apr 29, 2014, 5:07:24 PM4/29/14
to nltk-...@googlegroups.com
Hello,

Look at the difference between the two lines:
    • >>> parser = nltk.parse.malt.MaltParser(working_dir="/home/ubuntu/maltparser-1.7.2", mco="engmalt.linear-1.7")

    • 19:48

      MaltPipeline.py: 

    • parser = nltk.parse.malt.MaltParser(working_dir="home/ubuntu/maltparser-1.7.2", mco="engmalt.linear-1.7")



    You are missing / before home.

    Regards,

    Constantin 

    Marco Ippolito

    unread,
    Apr 30, 2014, 1:55:16 AM4/30/14
    to nltk-...@googlegroups.com
    Hi Constantin,

    thank you very much for your kind help in spotting such a stupid error I made.

    Kind regards.
    Marco
    > --
    > You received this message because you are subscribed to a topic in the
    > Google Groups "nltk-users" group.
    > To unsubscribe from this topic, visit
    > https://groups.google.com/d/topic/nltk-users/1Cst10_CwH8/unsubscribe.
    > To unsubscribe from this group and all its topics, send an email to
    > nltk-users+...@googlegroups.com.
    > For more options, visit https://groups.google.com/d/optout.

    Nouha Arfaoui

    unread,
    Aug 23, 2017, 7:22:49 PM8/23/17
    to nltk-users
    Dear Sir,

    Are you still working wilt MALT  and NLTK?
    I started a research project when I have to use Malt Naltk and python to show the dependencies.
    I did not find helpful tutorials/codes.

    Sincerely


    Reply all
    Reply to author
    Forward
    0 new messages