#!/usr/bin/perl =head1 NAME WordQuery.pm - provides a high-level and user-friendly interface for determining relationships between tokens in WordNet =head1 SYNOPSIS WordQuery.pm provides a high-level and user-friendly interface for querying items in WordNet. It is built on top of WordNet::QueryData which provides lower level access to WordNet. WordQuery accepts fully (term#pos#number), partially (term#pos), or unqualified terms (term) and automatically compares all possible senses of each word in a query. WordQuery tests for synonym, antonym, and hypernym relationships. See Usage for more information. =head1 USAGE Usage: WordQuery.pm WordQuery.pm should be initialized to increase query speed. Following initialization several functions may be called. The functionality is highlighted below. For all functions input words may be fully qualified (##), partially (#), or unqualified (). All possible senses are found and used in comparisons. This allows for functions to be used with raw text, part of speech (POS) tagged text, or disambiguated text. If a term is not in WordNet, false is returned ---- Initialization: WordQuery should first be initialized to increase query speed use WordQuery; my $wq = WordQuery->new(); #initialize WordQuery ---- isSynonym Description: Determines if two words are synonyms Usage: [1,2,3] = #wq->isAntonym($wordA, $wordB); Input: $wordA, $wordB = the two words to compare Optional Input: $directOnly = 1 if only direct synonyms should be checked Returns: 0 if not a synonym 1 if a direct synonym 2 is an indirect synonym Example: my $wq = WordQuery->new(); #initialize WordQuery my $result = $wq->isSynonym('warm', 'sweltering'); #returns true $result = $wq->isSynonym('warm', 'sweltering', 1); #returns false $result = $wq->isSynonym('sweltering', 'hot', 1); #returns true $result = $wq->isSynonym('sweltering#a', 'hot#a#1'); #returns true ---- isAntonym Description: Determines if two things are antonyms Usage: [1,2,3] = $wq->isAntonym($wordA, $wordB); Input: $wordA, $wordB = the two words to compare Optional input: $directOnly = 1 if only direct synonyms should be checked Returns: 0 if not a antonym 1 if a direct antonym 2 is an indirect antonym Examples: my $wq = WordQuery->new(); #initialize WordQuery my $result = $wq->isAntonym('hot', 'frozen'); #returns true $result = $wq->isAntonym('hot#a#1', 'frozen#a'); #returns true $result = $wq->isAntonym('warm', 'frozen', 1); #returns false $result = $wq->isAntonym('hot', 'frozen', 1); #returns true ----- isA Description: Takes a noun and determines if at some point in the WordNet hierarchy it is categorized as the hypernym Usage: [1,0] = $wq->isA($word, $category); Input: $word = the word to check an isA relationship of. The string is not required to be a noun, however only noun senses will be checked $category = the fully specified WordNet category (hypernym) Returns: 1 if $word isA $category, 0 otherwise Examples: my $wq = WordQuery->new(); #initialize WordQuery my $result = $wq->isA('train', 'transport#n#1'); #returns true $result = $wq->isA('train#n', 'transport#n#1'); #returns true $result = $wq->isA('train#n#1', 'transport#n#1'); #returns true $result = $wq->isA('train#v', 'transport#n#1'); #returns false ---- isHypernym: Description: Determines if the two words are hypernyms. If the word sense is not fully specified all possible senses will be checked. Note, this checks all senses of a word but not indirect or direct synonyms Usage: [1,0] = $wq->isHypernym($word1, $word2); Input: $wordA, $wordB = the two words to check for hypernymy. (e.g. $wordA isA $wordB) Returns: 1 if the words are hypernyms of one another, 0 otherwise Examples: my $wq = WordQuery->new(); #initialize WordQuery my $result = $wq->isHypernym('train', 'transport'); #returns true $result = $wq->isHypernym('train#v', 'transport'); #returns false $result = $wq->isHypernym('train#v#1', 'transport#n'); #returns false $result = $wq->isHypernym('train#v', 'transport#n#1'); #returns false ---- inWordNet: Description: Determines if any sense of the word is in WordNet Usage: [1,0] = $wq->inWordNet($word); Input: $word = the word to test if it is in WordNet Returns: 1 if the any sense of the word is in WordNet, 0 otherwise Examples: my $wq = WordQuery->new(); #initialize WordQuery my $result = $wq->inWordNet('hot'); #returns true $result = $wq->inWordNet('hot#a'); #returns true $result = $wq->inWordNet('hot#a#1'); #returns true $result = $wq->inWordNet('hot#v'); #returns false $result = $wq->inWordNet('braff'); #returns false =head1 INPUT See usage for input of specific functions =head1 Optional Arguments: See Usage for optional arguments of specific functions =head2 --