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

NAME

WordNet::Similarity::jcn - Perl module for computing semantic relatedness of word senses according to the method described by Jiang and Conrath (1997).

SYNOPSIS

use WordNet::Similarity::jcn;

use WordNet::QueryData;

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

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

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

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

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

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

DESCRIPTION

This module computes the semantic relatedness of word senses according to the method described by Jiang and Conrath (1997). This measure is based on a combination of using edge counts in the WordNet 'is-a' hierarchy and using the information content values of the WordNet 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

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

   use WordNet::Similarity::jcn;
   $measure = WordNet::Similarity::jcn->new($wn, '/home/sid/jcn.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 jcn 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 jcn module will have
on the first line 'WordNet::Similarity::jcn'. 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::' -- 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 synsets are represented as word#pos#sense
      strings, while for level 2, the synsets 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) 'infocontent::' -- The value for this parameter should be a string that
      specifies the path of an information content file containing the 
      frequency of occurrence of every WordNet concept in a large corpus. The
      format of this file is specified in a later section.

INFORMATION CONTENT

Three of the measures provided within the package require information content values of concepts (WordNet synsets) for computing the semantic relatedness of concepts. Resnik (1995) describes a method for computing the information content of concepts from large corpora of text. In order to compute information content of concepts, according to the method described in the paper, we require the frequency of occurrence of every concept in a large corpus of text. We provide these frequency counts to the three measures (Resnik, Jiang-Conrath and Lin measures) in files that we call information content files. These files contain a list of WordNet synset offsets along with their part of speech and frequency count. This may be followed by a 'ROOT' tag if the synset is the root of the taxonomy in WordNet. The information content file to be used is specified in the configuration file for the measure. If no information content file is specified, then the default information content file, generated at the time of the installation of the WordNet::Similarity modules, is used. A description of the format of these files follows. The FIRST LINE of this file MUST contain the version of WordNet that the file was created with. This should be present as a string of the form

wnver::<version>

For example, if WordNet version 1.7.1 was used for creation of the information content file, the following line would be present at the start of the information content file.

wnver::1.7.1

The rest of the file contains on each line a WordNet synset offset, part-of-speech and a frequency count, in the form

<offset><part-of-speech> <frequency> [ROOT]

without any leading or trailing spaces. For example, one of the lines of an information content file may be as follows.

63723n 667

where '63723' is a noun synset offset and 667 is its frequency count. If a synset with offset 1740 is the root of a noun 'is-a' taxonomy in WordNet and its frequency count is 17265, it will appear in the information content file as follows:

1740n 17265 ROOT

The ROOT tags are extremely significant in determining the top of the hierarchies and must not be omitted. Typically, frequency counts for the noun and verb hierarchies are present in each information content file.

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/

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.