|
NAMEWordNet::Similarity::wup - Perl module for computing semantic relatedness of word senses using the edge counting method of the of Wu & Palmer (1994)SYNOPSISuse WordNet::Similarity::wup; use WordNet::QueryData; my $wn = WordNet::QueryData->new(); my $wup = WordNet::Similarity::wup->new($wn); my $value = $wup->getRelatedness('dog#n#1', 'cat#n#1'); my ($error, $errorString) = $wup->getError(); die $errorString if $error; print "dog (sense 1) <-> cat (sense 1) = $value\n"; DESCRIPTIONResnik (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. Here we have implemented the original Wu & Palmer method, which uses node-counting.MethodsThis module defines the following methods:
DiscussionThe Wu & Palmer measure calculates relatedness by considering the depths of the two synsets in the WordNet taxonomies, along with the depth of the LCS. The formula is score = 2*depth(lcs) / (depth(s1) + depth(s2)). This means that 0 < score <= 1. The score can never be zero because the depth of the LCS is never zero (the depth of the root of a taxonomy is one). The score is one if the two input synsets are the same.USAGEThe semantic relatedness modules in this distribution are built as classes that define the following methods:new() getRelatedness() getError() getTraceString() See the WordNet::Similarity(3) documentation for details of these methods. TYPICAL USAGE EXAMPLESuse 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 FILEThe 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:
SEE ALSOperl(1), WordNet::Similarity(3), WordNet::QueryData(3)http://www.d.umn.edu/~mich0212/ http://www.d.umn.edu/~tpederse/similarity.html http://wordnet.princeton.edu http://www.ai.mit.edu/people/jrennie/WordNet/ AUTHORSTed Pedersen, University of Minnesota Duluth tpederse at d.umn.edu Jason Michelizzi, University of Minnesota Duluth mich0212 at d.umn.edu Siddharth Patwardhan, University of Utah, Salt Lake City sidd at cs.utah.edu COPYRIGHT AND LICENSECopyright (c) 2005, Ted Pedersen, Jason Michelizzi and Siddharth PatwardhanThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to The Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Note: a copy of the GNU General Public License is available on the web at <http://www.gnu.org/licenses/gpl.txt> and is included in this distribution as GPL.txt.
Visit the GSP FreeBSD Man Page Interface. |