Re: [nltk-users] Help! nltk.data.load error

298 views
Skip to first unread message
Message has been deleted

Richard Careaga

unread,
Jan 8, 2010, 8:17:28 PM1/8/10
to nltk-...@googlegroups.com
Try
grammar1 = nltk.data.load('/users/luke/mygrammar.cfg') if you are using *nix and 'luke' is your home directory and mygrammar.cfg is in that directory, or it's Win equivalent.

Luke wrote:
Hi:

I have the following error message when I try to load a .cfg file. I
used the following expression.

  
grammar1 = nltk.data.load('file:mygrammar.cfg')
    
The actual error message is as follows. Could anyone help me out?
Thanks much in advance.

  
Traceback (most recent call last):
 File "tree2.py", line 8, in <module>
   grammar1 = nltk.data.load('file:mygrammar.cfg')
 File "nltk/data.py", line 597, in load
 File "nltk/grammar.py", line 1036, in parse_cfg
 File "nltk/grammar.py", line 1199, in parse_grammar
ValueError: Unable to parse line 1: grammar1 = nltk.parse_cfg("""
Expected an arrow
    

Steven Bird

unread,
Jan 8, 2010, 8:56:59 PM1/8/10
to nltk-users
The original error message suggests that the file was found, but that
its content is not in the right format.
This suggested fix looks like it is for a different error (file not found).

Luke: can you show us the first few lines of your grammar file?

2010/1/9 Richard Careaga <leu...@gmail.com>:

> --
> You received this message because you are subscribed to the Google Groups
> "nltk-users" group.
> To post to this group, send email to nltk-...@googlegroups.com.
> To unsubscribe from this group, send email to
> nltk-users+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/nltk-users?hl=en.
>
>

Chongwon Park

unread,
Jan 8, 2010, 9:04:50 PM1/8/10
to nltk-...@googlegroups.com
Steven:

Thanks very much for your message.

Actually, I made a mistake. Originally, I included "grammar1 = nltk.parse.cfg(""" ... """)" in "mygrammar.cfg". Later I noticed that it should not be part of the .cfg file. After removing this part, the file loads correctly.

Indeed, the error message was right. The content was not in the right format. Thanks again!

Reply all
Reply to author
Forward
0 new messages