Thank you. I was able to run your code on Linux with no problems. The
only thing I changed was the new option on WordNet QueryData. I am
guessing that the location of the dictionary is for some reason an
issue for QueryData. Are you able to set an environment variable as
described here? I would suggest giving that a try, and seeing if that
solves the issue...
http://search.cpan.org/dist/WordNet-QueryData/QueryData.pm#LOCATING_THE_WORDNET_DATABASE
LOCATING THE WORDNET DATABASE
To use QueryData, you must tell it where your WordNet database is.
There are two ways you can do this: 1) by setting the appropriate
environment variables, or 2) by passing the location to QueryData when
you invoke the "new" function.
QueryData knows about two environment variables, WNHOME and
WNSEARCHDIR. If WNSEARCHDIR is set, QueryData looks for WordNet data
files there. Otherwise, QueryData looks for WordNet data files in
WNHOME/dict (WNHOME\dict on a PC). If WNHOME is not set, it defaults
to "/usr/local/WordNet-3.0" on Unix and "C:\Program Files\WordNet\3.0"
on a PC. Normally, all you have to do is to set the WNHOME variable to
the location where you unpacked your WordNet distribution. The
database files are normally unpacked to the "dict" subdirectory.
You can also pass the location of the database files directly to
QueryData. To do this, pass the location to "new":
Here's me running your code...
ukko(10): cat test1.pl
use WordNet::QueryData;
use WordNet::Similarity::path;
use WordNet::Similarity::vector;
use WordNet::Similarity::lin;
use WordNet::Similarity::res;
use WordNet::Similarity::wup;
##$wn = WordNet::QueryData->new("C:/WordNet/dict/");
$wn = WordNet::QueryData->new();
$measure = WordNet::Similarity::path->new($wn);
$str = "";
for (my $i=0; $i<@ARGV; $i++) {
for (my $j=0; $j<@ARGV; $j++) {
$one = $ARGV[$i];
$two = $ARGV[$j];
my $value = $measure->getRelatedness($one."#n#1",$two."#n#1");
my ($error, $errorString) = $measure->getError();
if ($error == 1) {
$value = -1;
}
if ($j < @ARGV - 1) {
$str = $str.$value."\t";
} else {
$str = $str.$value."\n";
}
}
}
print $str;
ukko(11): perl test1.pl cat dog
1 0.2
0.2 1
ukko(12): perl test1.pl mouse house
1 0.0714285714285714
0.0714285714285714 1
ukko(13): perl test1.pl xxxxxxxx house
-1 -1
-1 1
On Tue, Mar 29, 2016 at 12:02 PM, Wu Zhichen via RT
<bug-WordNet-Similarity@rt.cpan.org> wrote:
Show quoted text> Queue: WordNet-Similarity
> Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=113424 >
>
> My query is perl WordNetSim.pl word1 word2 word3 ...
>
>
> use WordNet::QueryData;
> use WordNet::Similarity::path;
> use WordNet::Similarity::vector;
> use WordNet::Similarity::lin;
> use WordNet::Similarity::res;
> use WordNet::Similarity::wup;
>
> $wn = WordNet::QueryData->new("C:/WordNet/dict/");
> $measure = WordNet::Similarity::path->new($wn);
>
> $str = "";
> for (my $i=0; $i<@ARGV; $i++) {
> for (my $j=0; $j<@ARGV; $j++) {
> $one = $ARGV[$i];
> $two = $ARGV[$j];
> my $value = $measure->getRelatedness($one."#n#1",$two."#n#1");
> my ($error, $errorString) = $measure->getError();
> if ($error == 1) {
> $value = -1;
> }
> if ($j < @ARGV - 1) {
> $str = $str.$value."\t";
> } else {
> $str = $str.$value."\n";
> }
> }
> }
> print $str;
>
> ________________________________________
> 发件人: TPEDERSE via RT [bug-WordNet-Similarity@rt.cpan.org]
> 发送时间: 2016年3月29日 21:10
> 收件人: Wu Zhichen
> 主题: [rt.cpan.org #113424] Some questions about WordNet Similarity
>
> <URL:
https://rt.cpan.org/Ticket/Display.html?id=113424 >
>
> Hi Jerry,
>
> Could you post the command or code you are running that is causing this error? That will help isolte the problem.
>
> Thanks!
> Ted
>
> On Tue Mar 29 03:58:26 2016, jerry_wzc@apex.sjtu.edu.cn wrote:
>> Dear WordNet Similarity Group:
>>
>> I'm a student who is trying to use the WordNet::Similarity tool you
>> developed. Now I'm facing some troubles using it.
>>
>> When I was using Resnik and Lin for computing, all the similarities
>> are 0.
>>
>> When I was using Wup, it said "Can't use an undefined value as an
>> ARRAY reference at c:/...../DepthFinder.pm line 182, <GEN8> line 66.“
>>
>> I don't know how to solve those problems, so I have to bother you for
>> helping me.
>>
>> I would appreciate that very much if you can offer your help! Thanks!
>>
>> Best regards,
>> Jerry Wu
>
>
>
>