WordNet::QueryData is a Perl module that has some handy functionality
with offsets.
http://search.cpan.org/dist/WordNet-QueryData/QueryData.pm
Below is an example where I get the offset for a synset specified by a
word#pos#sense (note that QueryData uses the first word,pos,sense in a
sysnet as a unique identifier for the synset, so it's refereeing to
the entire synset, not just that particular one) and then I use that
offset to get back the word. Note that if you don't give the part of
speech to the getSense method you will get back the word and the sense
number - I don't remember the details of why that is, but hopefully
this gives you some idea of what it can do with offsets.
marimba(1749): more qd5.pl
use WordNet::QueryData;
my $wn = WordNet::QueryData->new;
$wps = 'cat#n#1';
$offset = $wn->offset("$wps");
print "offset of $wps $offset\n";
$pos = 'n';
$wordForm = $wn->getSense($offset,$pos);
print "with pos : $wordForm\n";
$wordForm = $wn->getSense($offset);
print "without pos : $wordForm\n";
---------------------
marimba(1750): perl qd5.pl
offset of cat#n#1 2121620
with pos : cat#n#1
without pos : cat##1
Enjoy,
Ted
On Wed, Jul 27, 2011 at 3:27 AM, Villar Rodriguez, Esther
<esther...@tecnalia.com> wrote:
> Hi,
>
>
>
> I have just to obtain the synset from its offset. I have got its word sense
> (offset) and I suppose there is a way to ask for the synset. I have been
> reading the wordnet api but I havent found any way to directly achieve this.
> I supposed that the method would have to be of the WordNetDatabase class,
> but there are only methods to obtain all the synsets of a word form.
>
> Is there no way to get it directly with the offset? or do I have to get all
> the synsets and then search for the one I want?
>
> Kind regards
--
Ted Pedersen
http://www.d.umn.edu/~tpederse