View on
Danny Brian > Lingua-Wordnet > Lingua::Wordnet::Analysis



Annotate this POD

View/Report Bugs
Module Version: 0.74   Source  


Lingua::Wordnet::Analysis - Perl extension for high-level processing of Wordnet databases.


 use Lingua::Wordnet::Analysis;

 $analysis = new Lingua::Wordnet::Analysis;

 # How many articles of clothing have 'tongues'?
 $tongue = $wn->lookup_synset("tongue","n",2);
 @articles = $analysis->search($clothes,$tongue,"all_meronyms");
 # Are there any parts, of any kinds, of any shoes, made of glass?
 @shoe_types = $analysis->traverse("hyponyms",$shoes);
 $count = $analysis->search(@shoe_types,$glass,"stuff_meronyms");

 # Compute the intersection of two lists of synsets
 @array1 = $shoes->all_holonyms;
 @intersect = $analysis->intersection

 # Generate a list of the inherited comp_meronyms for "apple"
 @apple_hypernyms = $analysis->traverse("hypernyms",$apple);
 @apple_parts = $analysis->traverse("comp_meronyms",@apple_hypernyms);


Lingua::Wordnet::Analysis supplies high-level functions for analysis of word relationships. Most of these functions process and return potentially large amounts of data, so only use them if you "know what you are doing."

These functions could have been put into Lingua::Wordnet::Synset objects, but I wanted to keep those limited to core functionality. Besides, many of these functions have unproven usefulness.

Lingua::Wordnet::Analysis functions ^


Finds any occurance of SYNSET in the synset list ARRAY and the list's pointers. Returns a positive value if a match is found. match() does not traverse.


Searches all pointers of type POINTER in SYNSET1 for SYNSET2. search() is recursive, and will traverse all depths. Returns the number of matches.


Traverses all pointer types of POINTER in SYNSET and returns a list of all synsets found in the tree.


Returns a list of the coordinate sisters of SYNSET.


Returns a list of synsets which is the union of synsets LIST. The union consists of synsets which occur in any lists. This is useful, for example, for determining all the holonyms for two or more synsets.

$analysis->intersection(ref LIST)

Returns a list of synsets of the intersection of ARRAY1 list of synsets with ARRAY2 list of synsets. The intersection consists of synsets which occur in both lists. This is useful, for example, to determine which meronyms are shared by two synsets:

    @synsets = $analysis->intersection

Returns an integer value representing the distance in pointers between SYNSET1 and SYNSET2 using POINTER as the search path.


To print out an inherited meronym list, use traverse():

    $orange = $wn->lookup_synset("orange","n",1);
    @orange_hypernyms = $analysis->traverse("hypernyms",$orange);
    foreach ($analysis->traverse("all_meronyms",@orange_hypernyms)) {
        print $_->words, "\n";

Note that the inherited meronyms will not contain the direct meronyms of $orange.


There is tons that could go in this module ... submissions are welcome!

Lots of cleanup.

Need to add a search_path function that will return a path to a match as a linked list or hash of hashes.

Some might want inherited meronym/holonym trees.

Please send bugs and suggestions/requests to Development on this module is active as of Winter 2000.


Dan Brian <>



syntax highlighting: