The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

WordNet::SenseRelate::AllWords - perform Word Sense Disambiguation

SYNOPSIS

  use WordNet::SenseRelate::AllWords;
  use WordNet::QueryData;
  my $qd = WordNet::QueryData->new;
  my $wsd = WordNet::SenseRelate::AllWords->new (wordnet => $qd,
                                                 measure => 'WordNet::Similarity::lesk');
  my @results = $wsd->disambiguate ();

DESCRIPTION

WordNet::SenseRelate::AllWords implements an algorithm for Word Sense Disambiguation that uses measures of semantic relatedness. The algorithm is an extension of an algorithm described by Pedersen, Banerjee, and Patwardhan[1]. This implementation is similar to the original SenseRelate package but disambiguates every word in the given context rather than just single word.

Methods

Note: the methods below will die() on serious errors. Wrap calls to the methods in an eval BLOCK to catch the exceptions. See 'perldoc -f eval' for more information.

Example:

  my @res;
  eval {@res = $wsd->disambiguate (args...)}

  if ($@){
      print STDERR "An exception occurred ($@)\n";
  }
new

The constructor for this class. It will create a new instance and return a reference to the constructed object.

Parameters:

  wordnet      => REFERENCE : WordNet::QueryData object
  measure      => STRING    : name of a WordNet::Similarity measure
  config       => FILENAME  : config file for above measure
  outfile      => FILENAME  : name of a file for output (optional)
  compfile     => FILENAME  : file containing compound words
  stoplist     => FILENAME  : file containing list of stop words
  pairScore    => INTEGER   : minimum pairwise score (default: 0)
  contextScore => INTEGER   : minimum overall score (default: 0)
  trace        => INTEGER   : generate traces (default: 0)
  forcepos     => INTEGER   : do part-of-speech coercion (default: 0)

Returns:

  A reference to the constructed object.

Example:

  WordNet::SenseRelate::AllWords->new (wordnet => $query_data_obj,
                                       measure => 'WordNet::Similarity::lesk',
                                       trace   => 1);

The trace levels are:

  1 Show the context window for each pass through the algorithm.

  2 Display winning score for each pass (i.e., for each target word).

  4 Display the non-zero scores for each sense of each target
    word (overrides 2).

  8 Display the non-zero values from the semantic relatedness measures.

 16 Show the zero values as well when combined with either 4 or 8.
    When not used with 4 or 8, this has no effect.

 32 Display traces from the semantic relatedness module.

These trace levels can be added together. For example, by specifying a trace level of 3, the context window will be displayed along with the winning score for each pass.

disambiguate

Disambiguates all the words in the specified context and returns them as a list. If a word cannot be disambiguated, then it is returned "as is". A word cannot be disambiguated if it is not in WordNet or if no value exceeds the specified threshold.

The context parameter specifies the words to be disambiguated. It treats the value as one sentence. To disambiguate a document with multiple sentences, make one call to disambiguate() for each sentence.

Parameters:

  window => INTEGER    : the window size to use.  A window size of N means
                         that the window will include N words, including
                         the target word.  If N is an even number, there
                         will be one more word on the left side of the
                         target word than on the right.
  tagged => BOOLEAN    : true if the text is tagged, false otherwise
  scheme => normal|sense1|random|fixed : the disambiguation scheme to use
  context => ARRAY_REF : reference to an array of words to disambiguate

Returns: An array of disambiguated words.

Example:

  my @results =
    $wsd->disambiguate (window => 3, tagged => 0, context => [@words]);
getTrace

Gets the current trace string and resets it to "".

Parameters:

  None

Returns:

  The current trace string (before resetting it).  If the returned string
  is not empty, it will end with a newline.

Example:

  my $str = $wsd->getTrace ();
  print $str;

SEE ALSO

WordNet::Similarity::AllWords

The main web page for SenseRelate is

http://senserelate.sourceforge.net/

There are several mailing lists for SenseRelate:

http://lists.sourceforge.net/lists/listinfo/senserelate-users/

http://lists.sourceforge.net/lists/listinfo/senserelate-news/

http://lists.sourceforge.net/lists/listinfo/senserelate-developers/

REFERENCES

[1]

Ted Pedersen, Satanjeev Banerjee, and Siddharth Patwardhan (2005) Maximizing Semantic Relatedness to Perform Word Sense Disambiguation, University of Minnesota Supercomputing Institute Research Report UMSI 2005/25, March. http://www.msi.umn.edu/general/Reports/rptfiles/2005-25.pdf

AUTHORS

Jason Michelizzi, <jmichelizzi at users.sourceforge.net>

Ted Pedersen, <tpederse at d.umn.edu>

COPYRIGHT AND LICENSE

Copyright (C) 2004-2005 by Jason Michelizzi and Ted Pedersen

This 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.