The following little QueryData program will show you all the nouns in WordNet!
-------------------
use WordNet::QueryData;
my $wn = WordNet::QueryData->new;
@allnouns = $wn->listAllWords("n");
print "@allnouns";
koko_2,
The derivational links might be what you want. I think you'd be better off
not using WordNet for this task. The derivational links aren't specific,
in that you don't know what type of derivation it is. And they're not very
comprehensive. But, nonetheless, they're something...
The following/attached program demonstrates. (Also at
http://wordnet.princeton.edu/~ben/derived.pl )
Best,
Ben
e.g.
$ perl derived.pl illegal long gusty revolution
illegal => {
illegal
illegality
}
long => {
long
longer
longing
longness
}
gusty => {
gust
gusty
}
revolution => {
revolt
revolution
revolutionary
revolutionise
revolutionism
revolutionist
revolutionize
revolve
}
#### derived.pl ############################
#!/usr/bin/perl
use strict;
use warnings;
use WordNet::QueryData;
my $qd = WordNet::QueryData->new;
# transform word or word#pos into word#pos#sense
sub senses {
while (grep !(2 == tr/#/#/), @_) {
@_ = map $qd->queryWord($_), @_;
}
@_
}
# transform word#pos#sense into word -- change the '.*?' to '.*' to keep #pos
sub word { local $_ = @_ ? shift : $_; /^(.*?)#/ ? $1 : $_ }
# follow derivational links recursively
sub derived {
local $_ = shift;
my $count;
my %words;
my %senses;
$senses{$_}++ for senses $_;
do {
$count = keys %words;
for my $sense (keys %senses) {
for my $rel (qw/deri/) {
$senses{$_}++ for $qd->queryWord($sense, $rel);
}
}
$words{word $_}++ for keys %senses;
} while $count != keys %words; # stop when we've not added any words
sort keys %words;
}
# test it
my @words;
for (reverse 0..$#ARGV) {
unshift @words, splice @ARGV, $_, 1 unless -f $ARGV[$_];
}
my $count = @words;
print "Enter a word (Control-D/Enter to stop)\n" unless @words;
while (1) {
last if $count and not @words;
$_ = @words ? shift @words : <>;
last unless defined;
chomp;
last unless length;
print "$_\n" for "$_ => {", map("\t$_", derived($_)), "}";
}