The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WordNet::Similarity::lesk - Perl module for computing semantic relatedness of word senses using gloss overlaps as decribed by Banerjee and Pedersen (2002) -- a method that adapts the Lesk approach to WordNet.

SYNOPSIS

  use WordNet::Similarity::lesk;

  use WordNet::QueryData;

  my $wn = WordNet::QueryData->new();

  my $lesk = WordNet::Similarity::lesk->new($wn);

  my $value = $lesk->getRelatedness("car#n#1", "bus#n#2");

  ($error, $errorString) = $lesk->getError();

  die "$errorString\n" if($error);

  print "car (sense 1) <-> bus (sense 2) = $value\n";

DESCRIPTION

Lesk (1985) proposed that the relatedness of two words is proportional to to the extent of overlaps of their dictionary definitions. Banerjee and Pedersen (2002) extended this notion to use WordNet as the dictionary for the word definitions. This notion was further extended to use the rich network of relationships between concepts present is WordNet. This adapted lesk measure has been implemented in this module.

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

To create an object of the lesk measure, we would have the following lines of code in the perl program.

   use WordNet::Similarity::lesk;
   $measure = WordNet::Similarity::lesk->new($wn, '/home/sid/lesk.conf');

The reference of the initialized object is stored in the scalar variable '$measure'. '$wn' contains a WordNet::QueryData object that should have been created earlier in the program. The second parameter to the 'new' method is the path of the configuration file for the lesk measure. If the 'new' method is unable to create the object, '$measure' would be undefined. This, as well as any other error/warning may be tested.

   die "Unable to create object.\n" if(!defined $measure);
   ($err, $errString) = $measure->getError();
   die $errString."\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 behaviour of the measures of semantic relatedness can be controlled by using configuration files. These configuration files specify how certain parameters are initialized within the object. A configuration file may be specififed 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 the name of the module ON THE FIRST LINE of the file. For example, a configuration file for the lesk module will have on the first line 'WordNet::Similarity::lesk'. This is followed by the various parameters, each on a new line and having the form 'name::value'. The 'value' of a parameter is optional (in case of boolean parameters). In case 'value' is omitted, we would have just 'name::' on that line. Comments are supported 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::' -- The value of this parameter specifies the level of tracing that should be employed for generating the traces. This value is an integer 0, 1 or 2. A value of 0 switches tracing off. A value of 1 displays as traces only the gloss overlaps found. A value of 2 displays as traces, all the text being compared.

(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) 'stop::' -- The value is a string that specifies the path of a file containing a list of stop words that should be ignored for the gloss overlaps.

(d) 'stem::' -- can take values 0 or 1 or the value can be omitted, in which case it takes the value 1, i.e. switches 'on' stemming. A value of 0 switches stemming 'off'. When stemming is enabled, all the words of the glosses are stemmed before their overlaps are determined.

(e) 'normalize::' -- can take values 0 or 1 or the value can be omitted, in which case it takes the value 1, i.e. switches 'on' normalizing of the score. A value of 0 switches normalizing 'off'. When normalizing is enabled, the score obtained by counting the gloss overlaps is normalized by the size of the glosses. The details are described in Banerjee Pedersen (2002).

SEE ALSO

perl(1), WordNet::Similarity(3), WordNet::QueryData(3)

http://www.d.umn.edu/~patw0006

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

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

http://groups.yahoo.com/group/wn-similarity

AUTHORS

  Siddharth Patwardhan, <patw0006@d.umn.edu>
  Ted Pedersen, <tpederse@d.umn.edu>

COPYRIGHT AND LICENSE

Copyright 2003 by Siddharth Patwardhan and Ted Pedersen

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