NAME

WordNet::SenseRelate::WordToSet - Find the WordNet Sense of a Target Word that is Most Related to a Given Set of Words

SYNOPSIS

use WordNet::SenseRelate::WordToSet;
use WordNet::QueryData;
my $qd = WordNet::QueryData->new;

my %options = (measure => 'WordNet::Similarity::jcn',
               wordnet => $qd);

my $mod = WordNet::SenseRelate::WordToSet->new (%options);

my $res = $mod->disambiguate (target => 'bank',
                            context => [qw/money cash dollar/]);

# all senses for target and their scores are returned
# we will just print the sense most related to the set

$best_score = -100;
foreach my $key (keys %$res) {
  next unless defined $res->{$key};
  if ($res->{$key} > $best_score) {
      $best_score = $res->{$key};
      $best = $key;
  }
}

# let's call WordNet::QueryData to get the gloss of the most
# related sense of the target to the set 

print "$best : ", join(", ", $qd->querySense($best, "glos")), "\n";

my $res = $mod->disambiguate (target => 'bank',
                            context => [qw/river shore slope water/]);

# all senses for target and their scores are returned
# we will just print the sense most related to the set

$best_score = -100;
foreach my $key (keys %$res) {
  next unless defined $res->{$key};
  if ($res->{$key} > $best_score) {
      $best_score = $res->{$key};
      $best = $key;
  }
}

# let's call WordNet::QueryData to get the gloss of the most
# related sense of the target to the set 

print "$best : ", join(", ", $qd->querySense($best, "glos")), "\n";

DESCRIPTION

WordNet::SenseRelate::WordToSet finds the sense of a given target word that is most related to the words in a given set.

Methods

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

new

The constructor for this class.

Parameters:

wordnet   => REFERENCE : WordNet::QueryData object (required)
measure   => STRING    : name of a WordNet::Similarity measure (required)
config    => FILENAME  : path to a config file for above measure
trace     => INTEGER   : generate traces (default : 0)
threshold => NUMBER    : similarity scores less than this are ignored

Returns:

A reference to the constructed object or undef on error.

The trace levels are:

1 show non-zero scores from the semantic relatedness measure

2 show zero & undefined scores from the relatedness measure
  (no effect unless combined with level 1)

4 show traces from the semantic relatedness measure

Note: the trace levels can be added together to achieve a combined effect. For example, to show the non-zero scores, the zero scores, and the traces from the measure, use level 7.

disambiguate

Disambiguates the target word

Parameters:

target  => STRING    : the target word to disambiguate (required)
context => REFERENCE : a reference to an array of context words

Returns:

A hash reference.  The keys of the hash will be the senses of the
target word, and the values will be the score for each sense.
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

L<http://senserelate.sourceforge.net/>

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.
L<http://www.msi.umn.edu/general/Reports/rptfiles/2005-25.pdf>

AUTHORS

Ted Pedersen, University of Minnesota, Duluth
tpederse at d.umn.edu

Jason Michelizzi

Last modified by : $Id: WordToSet.pm,v 1.10 2008/04/07 03:29:47 tpederse Exp $

COPYRIGHT

Copyright (C) 2005-2008 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.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA