WordNetCorpusReader error?

521 views
Skip to first unread message

project2501

unread,
Dec 11, 2008, 9:22:29 AM12/11/08
to nltk-dev
Hi,
I tried the suggestion given to me a while ago for the new wordnet
API on 0.9.6 and get this error:

>>> wn.Synset._from_pos_and_offset('n', 8685677)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'WordNetCorpusReader' object has no attribute 'Synset'

Maybe there was an adjustment to the API since then?

thanks for any tips!
Darren

On Fri, 2008-10-31 at 15:01 -0600, Steven Bethard wrote:
> Ahh, yes. That's what I thought you might be doing. Note the
> documentation for the -o option describes these as "synset offsets",
> not
> "synset IDs" (http://wordnet.princeton.edu/man/wn.1WN):
>
> -o
> Display synset offset of each synset.
>
> In the new WordNet API, you can use Synset._from_pos_and_offset to get
> the same kind of functionality:
>
> >>> wn.Synset._from_pos_and_offset('n', 8685677)
> Synset('sign_of_the_zodiac.n.01')
>
> Steve

Steven Bethard

unread,
Dec 11, 2008, 1:30:28 PM12/11/08
to nltk...@googlegroups.com
On Thu, Dec 11, 2008 at 7:22 AM, project2501 <dar...@ontrenet.com> wrote:
> I tried the suggestion given to me a while ago for the new wordnet
> API on 0.9.6 and get this error:
>
>>>> wn.Synset._from_pos_and_offset('n', 8685677)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> AttributeError: 'WordNetCorpusReader' object has no attribute 'Synset'
>
> Maybe there was an adjustment to the API since then?

Yes. When Edward added the WordNetCorpusReader, he changed a bunch of the APIs.

>>> from nltk.corpus import wordnet
>>> wordnet._synset_from_pos_and_offset('n', 8685677)
Synset('sign_of_the_zodiac.n.01')

I don't know where the documentation for the new APIs are though - I
just found this by doing ``dir(wordnet)``. Can someone point Darren to
the new APIs?

Steve

> On Fri, 2008-10-31 at 15:01 -0600, Steven Bethard wrote:
>> Ahh, yes. That's what I thought you might be doing. Note the
>> documentation for the -o option describes these as "synset offsets",
>> not
>> "synset IDs" (http://wordnet.princeton.edu/man/wn.1WN):
>>
>> -o
>> Display synset offset of each synset.
>>
>> In the new WordNet API, you can use Synset._from_pos_and_offset to get
>> the same kind of functionality:
>>
>> >>> wn.Synset._from_pos_and_offset('n', 8685677)
>> Synset('sign_of_the_zodiac.n.01')
>>
>> Steve
>
> >
>



--
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
--- Bucky Katt, Get Fuzzy

Ewan Klein

unread,
Dec 11, 2008, 5:44:36 PM12/11/08
to nltk-dev
We don't have the Howtos properly up and running yet, but for the time
being, I think
the following has got up-to-date info on the WordNet API:

http://code.google.com/p/nltk/source/browse/trunk/nltk/doc/howto/wordnet.html

--Ewan

Steven Bird

unread,
Dec 14, 2008, 6:41:29 AM12/14/08
to nltk...@googlegroups.com
We'll have the HOWTOs ready by the end of the week. Here's the WordNet one:

http://nltk.googlecode.com/svn/trunk/doc/howto/wordnet.html

(this version has the MIME type set so it's a bit easier on the eyes.)

-Steven

2008/12/12 Ewan Klein <ewan....@googlemail.com>:

Darren Govoni

unread,
Dec 16, 2008, 8:06:34 AM12/16/08
to nltk...@googlegroups.com
Awesome! Thanks guys.

Steven Bird

unread,
Dec 18, 2008, 7:48:46 PM12/18/08
to nltk...@googlegroups.com
2008/12/14 Steven Bird <s...@csse.unimelb.edu.au>:

> We'll have the HOWTOs ready by the end of the week.

Here they are:

http://nltk.googlecode.com/svn/trunk/doc/howto/index.html

And I've set up a more convenient URL to remember:

http://www.nltk.org/howto

Some of them have quite a few errors, and I'd be grateful for any help
updating our doctests:

http://code.google.com/p/nltk/source/browse/trunk/nltk/nltk/test

Thanks,
-Steven

Reply all
Reply to author
Forward
0 new messages