NAME

WordNet::Similarity::random - Perl module for computing semantic relatedness of word senses using a random measure.

SYNOPSIS

use WordNet::Similarity::random;

use WordNet::QueryData;

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

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

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

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

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

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

DESCRIPTION

This module generates random numbers as a measure of semantic relatedness of word senses. It is possible to assign a random value for a word sense pair and return the same value if the same word sense pair is passed as input. It is also possible to generate a new random value for the same word sense pair every time.

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 random measure, we would have the following lines of code in the Perl program.

use WordNet::Similarity::random;
$measure = WordNet::Similarity::random->new($wn, '/home/sid/random.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 random 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 semantic 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 within 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 random module will have on the first line 'WordNet::Similarity::random'. 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 in the way in which the synsets are displayed in the output. 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. For module enabling caching implies that a previously generated random value will be reused if the same word sense pair occurs again. If caching is disabled for every word sense pair a new random number will be generated.

(c) 'maxrand::' -- specifies the maximum random number that can be generated.

SEE ALSO

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

http://www.cs.utah.edu/~sidd

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

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

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

AUTHORS

Siddharth Patwardhan, <sidd@cs.utah.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.