NAME

WordNet::Query - perl interface for noun relations of WordNet

SYNOPSIS

use WordNet::Query;

print "Definition: ", &gloss ("car\#1"), "\n"; print "Synset: ", join (", ", &syns ("car\#1")), "\n"; print "Hypernyms: ", join (", ", &hype ("car\#1")), "\n"; my @hypes = &hype("car\#1"); print "Hype Synset: ", join (", ", &syns ($hypes[0])), "\n"; print "Hype-Hypernyms: ", join (", ", &hype ($hypes[0])), "\n"; print "Hyponyms: ", join (", ", &hypo ("car\#1")), "\n"; print "Meronyms: ", join (", ", &mero ("car\#1")), "\n"; print "Holonyms: ", join (", ", &holo ("roof\#2")), "\n";

my @sensearray = &syns ("car");

print "Num Senses: ", scalar @sensearray, "\n"; for (my $i=0; $i < scalar @sensearray; $i++) { print $i+1, ") ", join (", ", @{$sensearray[$i]}), "\n"; }

DESCRIPTION

The WordNet::Query perl module uses the 'wn' command-line program to give a more palatable interface to the WordNet system. Before the WordNet perl module can be used, the WordNet C code must be installed on your system and the 'wn' executable must be located in a directory that is part of your PATH variable.

When a query is performed, the module gathers data from 'wn', caches it in memory and returns the requested information. This mechanism makes accessing WordNet information both efficient and more natural. The WordNet module requires little effort to traverse the various graphs of information that are available in the WordNet system.

USAGE

The WordNet::Query module includes six exported functions, each of which operate in two different modes. The functions are:

syns - Returns the synonym set of the provided word

gloss - Returns the glossary definition of the provided word

hype - Returns all hypernyms one level above the provided word

hypo - Returns all hyponyms one level below the provided word

mero - Returns all meronyms (part/member/substance of parents) of the provided word

holo - Returns all holonyms (part/member/substance of children) of the provided word

Each word accepts a single string that is the word to be queried. In the case that the exact sense of the word is known, that may be provided in the string using the #S notation (where 'S' is the sense number). For example, 'car#1' refers to the first sense of the word 'car'.

The output of each of these function depends on the format of the input and is probably best described by the examples provided in the SYNOPSIS section (above). Generally, if a specific sense is provided (e.g. 'window#2'), then a list of strings is returned, one for each found instance of the requested object. In the case of the 'gloss' function, a single item is returned (the single definition of that word). If no specific sense is provided, then an array of references is returned. Each reference will point to a list of strings, corresponding to the list that would have been returned given a specific sense query. The array of referneces is ordered according to sense number, with sense #1 coming first and the largest sense coming last. i.e. add one to the array index to get the sense number.

NOTES

Requires existence of WordNet command line program, 'wn'. Currently only allows WordNet queries on noun forms.

COPYRIGHT

Copyright 1999 Jason Rennie <jrennie@ai.mit.edu> All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

perl(1)

http://www.cogsci.princeton.edu/~wn/

http://www.ai.mit.edu/~jrennie/WordNet/

LOG

$Log: Query.pm,v $ Revision 1.2 1999/09/15 19:53:28 jrennie add URL

Revision 1.1 1999/09/15 13:27:54 jrennie new Query directory

Revision 1.3 1999/07/22 21:12:25 jrennie add lower; lowercase everything; put all verbosity output on STDERR

Revision 1.2 1999/07/22 18:54:24 jrennie add hype_set, level functions; have all parse_* functions return -1 if nothing is found; have export functions return empty list or undef if nothing is found

Revision 1.1 1999/07/21 20:08:51 jrennie rename from WordNet.pm; modify initialization code to allow direct access to findtheinfo function; in future, plan to rely soley on findtheinfo (no more command-line 'wn' execution)

Revision 1.5 1999/07/20 16:17:09 jrennie missing '>' in hash dereference

Revision 1.4 1999/07/19 14:19:53 jrennie use CVS for versioning ($VERSION line taken from CPAN suggestion)

Revision 1.3 1999/07/19 14:09:19 jrennie various fixes in parsing of 'wn' output -- particularly for special cases ('wn' does not have the requested information)

Revision 1.2 1999/07/16 19:51:06 jrennie deal with empty holo or mero wn output (different from other queries)

Revision 1.1.1.1 1999/07/16 18:27:02 jrennie move WordNet to separate directory

Revision 1.9 1999/07/16 18:04:12 jrennie bug fix---forgot to convert synlist to hash

Revision 1.8 1999/07/16 14:55:48 jrennie various clean up to make "use strict" happy; do the right thing for top and bottom of tree

Revision 1.7 1999/07/15 16:41:09 jrennie updated documentation

Revision 1.6 1999/07/15 15:27:42 jrennie allow arbitrary sense querying

Revision 1.5 1999/07/14 22:38:48 jrennie complete rewrite; created separate function for each aspect of wordnet (gloss, synset, hype, hypo, mero, holo); still need to allow for querying w/o a specific sense

Revision 1.4 1999/07/13 15:28:22 jrennie add example for ambiguous mode

Revision 1.3 1999/07/13 15:16:50 jrennie Follow guidelines in perl FAQ

Revision 1.2 1999/07/13 13:48:09 jrennie quote query words passed to wn