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

NAME

WordNet::Similarity::vector - Perl module for computing semantic relatedness of word senses using second order co-occurrence vectors of glosses of the word senses.

SYNOPSIS

  use WordNet::Similarity::vector;

  use WordNet::QueryData;

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

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

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

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

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

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

DESCRIPTION

Schütze (1998) creates what he calls context vectors (second order co-occurrence vectors) of pieces of text for the purpose of Word Sense Discrimination. This idea is adopted by Patwardhan and Pedersen to represent the word senses by second-order co-occurrence vectors of their dictionary (WordNet) definitions. The relatedness of two senses is then computed as the cosine of their representative gloss vectors.

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

  use WordNet::Similarity::vector;
  $measure = WordNet::Similarity::vector->new($wn, '/home/sid/vector.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 vector 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 vector module will have on the first line 'WordNet::Similarity::vector'. 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) 'relation::' -- The value is a filename (with complete path) of a file that contains a list of WordNet-relations. The vector module combines the glosses of synsets related to the target synsets by these relations, and forms the gloss-vector from this combined gloss. The format of the relation file is specified later in the documentation.

(c) 'vectordb::' -- Value is a Berkeley DB database file containing word vectors, i.e. co-occurrence vectors for all the words in the WordNet glosses.

(d) 'stop::' -- The value is a string that specifies the path of a file containing a list of stop words that should be ignored in the gloss vectors.

(e) 'compounds::' -- The value is a string that specifies the path of a file containing a list of compound words in WordNet.

(f) '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 vectors are created.

(g) '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.

(h) 'maxCacheSize::' -- takes a non-negative integer value. The value indicates the size of the cache, used for storing the computed relatedness value.

RELATION FILE FORMAT

The relation file starts with the string "VectorRelationFile" on the first line of the file. Following this, on each consecutive line, a relation is specified in the form --

func(func(func... (func)...)) [weight]

Where "func" can be any one of the following functions:

hype() = Hypernym of hypo() = Hyponym of holo() = Holonym of mero() = Meronym of attr() = Attribute of also() = Also see sim() = Similar enta() = Entails caus() = Causes part() = Particle pert() = Pertainym of glos = gloss (without example) example = example (from the gloss) glosexample = gloss + example syns = the synset of the concept

Each of these specifies a WordNet relation. And the outermost function in the nesting can only be one of glos, example, glosexample or syns. The functions specify which glosses to use for forming the gloss vector of the synset. An optional weight can be specified to weigh the contribution of that relation in the overall score.

For example,

glos(hype(hypo)) 0.5

means that the gloss of the hypernym of the hyponym of the synset is used to form the gloss vector of the synset, and the values in this vector are weighted by 0.5. If one of "glos", "example", "glosexample" or "syns" is not specified as the outermost function in the nesting, then "glosexample" is assumed by default. This implies that

glosexample(hypo(also))

and

hypo(also)

are equivalent as far as the measure is concerned.

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>
  Satanjeev Banerjee, <banerjee+@cs.cmu.edu>

COPYRIGHT AND LICENSE

Copyright 2003 by Siddharth Patwardhan, Ted Pedersen and Satanjeev Banerjee

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

1 POD Error

The following errors were encountered while parsing the POD:

Around line 1014:

Non-ASCII character seen before =encoding in 'Schütze'. Assuming UTF-8