> I would have thought querySense("beautiful#a#1","syns") would return an
> array containing the words after "==>" in the output of "/usr/local/
> WordNet-3.0/bin/wn 'beautiful' -synsa", i.e. starting with "beautious".
> Instead the synset only seems to contain the word itself.
>
> What am I doing wrong?
The words after '==>' in the output of wn beautiful -synsa are probably
'satellite' synsets, rather than synonyms. The organization of most
adjectives is different than the other parts of speech. Usually there is
a pair of roughly-antonymous 'head' synsets, each with related 'satellite'
synsets (the terminology coming from the arrangement:
satellite1 satellite1
| |
satellite2 -- head1 -- head2 -- satellite2
| |
satellite3 satellite3
e.g. in the 'beautiful' case,
head1: { beautiful -- (delighting the senses ... }
satellite1: { beauteous }
satellite2: { bonny, bonnie, comely, fair, sightly }
satellite3: { dishy }
...
vs.
head2: { ugly -- (displeasing to the senses ... }
satellite1: { disfigured }
satellite2: { evil-looking } # <-- really?
satellite3: { fugly }
The 'syns' relation is only for 'true' synonyms (words in the same
synset). The 'sim' relation returns the satellites (if the synset's a
head) or the head (if the synset's a satellite). And then you'd want to
call 'syns' on the returned results.
#!/usr/bin/perl
use strict;
use warnings;
use WordNet::QueryData;
my $wn = WordNet::QueryData->new( noload => 1 );
sub thesaurus {
my @forms = map $wn->validForms($_), @_;
my @sense = map $wn->querySense($_), @forms;
my @adj = map $wn->querySense($_, 'sim'), grep /#a#/, @sense;
my @all_syns = map $wn->querySense($_, 'syns'), @sense, @adj;
}
print "Syns: ", join("\t", thesaurus "beautiful"), "\n";
__END__
prints:
Syns: beautiful#a#1 beautiful#a#2 beauteous#a#1 bonny#a#1
bonnie#a#1 comely#a#2 fair#a#3 sightly#a#1 dishy#a#1
exquisite#a#4 fine-looking#a#1 good-looking#a#1
better-looking#a#1 handsome#a#1 well-favored#a#1
well-favoured#a#1 glorious#a#3 resplendent#a#1 splendid#a#1
splendiferous#a#1 gorgeous#a#1 lovely#a#1 picturesque#a#1
pretty#a#1 pretty-pretty#a#1 pulchritudinous#a#1
ravishing#a#1 scenic#a#1 stunning#a#4 pleasant#a#1