NAME
WordNet::Similarity::wup - Perl module for computing semantic relatedness of word senses using the edge counting method of the Resnik (1999) revision of Wu & Palmer (1994)
SYNOPSIS
use WordNet::Similarity::wup;
use WordNet::QueryData;
my $wn = WordNet::QueryData->new();
my $object = WordNet::Similarity::wup->new($wn);
my $value = $object->getRelatedness('dog#n#1', 'cat#n#1');
my ($error, $errorString) = $object->getError();
die "$errorString" if $error;
print "dog (sense 1) <-> cat (sense 1) = $value\n";
DESCRIPTION
Resnik (1999) revises the Wu & Palmer (1994) method of measuring semantic relatedness. Resnik uses use an edge distance method by taking into account the most specific node subsuming the two concepts.
USAGE
The semantic relatedness modules in this distribution are built as classes that expose the following methods:
new()
getRelatedness()
getError()
getTraceString()
See the WordNet::Similarity(3) documentation for details of these methods.
TYPICAL USAGE EXAMPLES
use WordNet::Similarity::wup;
my $measure->new($wn, 'wup.conf');
'$wn' contains a WordNet::QueryData object that should have been constructed already. The second (and optional) parameter to the 'new' method is the path of a configuration file for the Wu-Palmer measure. If the 'new' method is unable to construct the object, then '$measure' will be undefined. This may be tested.
my ($error, $errorString) = $measure->getError ();
die $errorString."\n" if $err;
To find the sematic relatedness of the first sense of the noun 'car' and the second sense of the noun 'bus' using the measure, we would write the following piece of code:
$relatedness = $measure->getRelatedness('car#n#1', 'bus#n#2');
To get traces for the above computation:
print $measure->getTraceString();
However, traces must be enabled using configuration files. By default traces are turned off.
CONFIGURATION FILE
The behavior of the measures of semantic relatedness can be controlled by using configuration files. These configuration files specify how certain parameters are initialized with the object. A configuration file may be specified as a parameter during the creation of an object using the new method. The configuration files must follow a fixed format.
Every configuration file starts with the name of the module ON THE FIRST LINE of the file. For example, a configuration file for the wup module will have on the first line 'WordNet::Similarity::wup'. This is followed by the various parameters, each on a new line and having the form 'name::value'. The 'value' of a parameter is option (in the case of boolean parameters). In case 'value' is omitted, we would have just 'name::' on that line. Comments are allowed in the configuration file. Anything following a '#' is ignored till the end of the line.
The module parses the configuration file and recognizes the following parameters:
(a) 'trace::' -- can take values 0, 1, or 2 or the value can be omitted, in which case it sets the trace level to 1. Trace level 0 implies no traces. Trace level 1 and 2 imply tracing is 'on', the only difference being the way in which the synsets are displayed in the traces. For trace level 1, the sysnsets are represented in word#pos#sense strings, while for level 2, the sysnets are represented as word#pos#offset strings.
(b) 'cache::' -- can take values 0 or 1 or the value can be omitted, in which case it takes the value 1, i.e., switches 'on' caching. A value of 0 switches caching 'off'. By default caching is enabled.
(c) 'cachesize::' -- can take any non-negative integer value or the value can be omitted, in which case it takes the value 1000. A value, n, such that n > 0 means that n relatedness queries will be cached. If n = 0, then no queries will be cached. Setting cachesize to zero has the same effect as setting cache to zero, but setting cache to zero is more efficient. Caching and tracing at the same time can result in excessive memory usage because the trace strings are also cached. If you intend to perform a large number of relatedness queries, then you should probably turn tracing off.
SEE ALSO
perl(1), WordNet::Similarity(3), WordNet::QueryData(3)
http://www.d.umn.edu/~mich0212/
http://www.d.umn.edu/~tpederse/similarity.html
http://www.cogsci.princeton.edu/~wn/
http://www.ai.mit.edu/people/jrennie/WordNet/
AUTHORS
Jason Michelizzi, <mich0212@d.umn.edu>
Ted Pedersen, <tpederse@d.umn.edu>
Siddharth Patwardhan <sidd@cs.utah.edu>
COPYRIGHT AND LICENSE
Copyright 2003 by Jason Michelizzi, Ted Pedersen, and Siddharth Patwardhan
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.