Skip Menu |

This queue is for tickets about the WordNet-Similarity CPAN distribution.

Report information
The Basics
Id: 79065
Status: resolved
Priority: 0/
Queue: WordNet-Similarity

People
Owner: TPEDERSE [...] cpan.org
Requestors: NGLENN [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 2.05
Fixed in: (no value)



Subject: Detecting WN2 and WN3 filetypes on Windows
The current version of this module assumes that Windows users have the old style WordNet files installed, even though the default directory is labeled as WordNet 3.0. WordNet 3.0 has not been released in a Windows installer; for research at my university, we normally use Java libraries, etc., and so are not tied to this. We just download the "Unix-like" distribution and put the files somewhere. They're perfectly usable. The problem is in utils/wnDepths.pl. I am including a patch which discovers the type of files used by looking for "noun.dat" and "data.noun", etc. and using the one that is found.
Subject: Changed-method-of-detecting-WN-2-and-WN-3-style-dict.patch
From e5a6c7593aefd75fe21d4a712fbcbc127b1a6653 Mon Sep 17 00:00:00 2001 From: Nathan Glenn <garfieldnate@gmail.com> Date: Fri, 17 Aug 2012 18:46:20 -0400 Subject: [PATCH 1/1] Changed method of detecting WN 2- and WN 3-style dictionary files. The old version assumed that Windows users would have the older file types. --- utils/wnDepths.pl | 28 ++++++++++++++++++---------- 1 files changed, 18 insertions(+), 10 deletions(-) diff --git a/utils/wnDepths.pl b/utils/wnDepths.pl index b8bd11e..a01149d 100755 --- a/utils/wnDepths.pl +++ b/utils/wnDepths.pl @@ -80,6 +80,20 @@ else # even for 64-bit Windows. See here for why: # http://www.perlmonks.org/index.pl?node_id=315372 my $wnpath = ($^O =~ /^MSWin/i) ? $wnPCPath : $wnUnixPath; + +# determine the filenames for the noun and verb databases; +# these names changed between WN 2.1 and 3.0 +my $nounFile = do{ + my $twoPointOne = File::Spec->catfile($wnpath, "noun.dat"); + if(-f $twoPointOne){ $twoPointOne; } + else { File::Spec->catfile($wnpath, "data.noun"); } +}; + +my $verbFile = do{ + my $twoPointOne = File::Spec->catfile($wnpath, "verb.dat"); + if(-f $twoPointOne){ $twoPointOne; } + else { File::Spec->catfile($wnpath, "data.verb"); } +}; print STDERR "Loading WordNet::QueryData... "; my $wn = WordNet::QueryData->new($wnpath); unless ($wn) @@ -97,9 +111,7 @@ print STDERR "done\n"; # Find top-level nodes for nouns my %top_level; -my $datafile = File::Spec->catfile($wnpath, "data.noun"); -$datafile = File::Spec->catfile($wnpath, "noun.dat") if ($^O =~ m/^MSWin/i); -open FH, "$datafile" or die "Cannot open $datafile: $!"; +open FH, "$nounFile" or die "Cannot open $nounFile: $!"; my $line; while ($line = <FH>) { @@ -116,9 +128,7 @@ if ($opt_verbose) } # Find top-level nodes for verbs -$datafile = File::Spec->catfile($wnpath, "data.verb"); -$datafile = File::Spec->catfile($wnpath, "verb.dat") if ($^O =~ /MSWin/i); -open FH, "$datafile" or die "Cannot open $datafile: $!"; +open FH, "$verbFile" or die "Cannot open $verbFile: $!"; while($line = <FH>) { next if substr($line, 0, 2) eq " "; @@ -314,13 +324,11 @@ sub findLeafs my $file; if ($pos eq "n") { - $file = File::Spec->catfile($wnpath, "data.noun"); - $file = File::Spec->catfile($wnpath, "noun.dat") if $^O =~ /MSWin/i; + $file = $nounFile; } elsif ($pos eq "v") { - $file = File::Spec->catfile($wnpath, "data.verb"); - $file = File::Spec->catfile($wnpath, "verb.dat") if $^O =~ /MSWin/i; + $file = $verbFile; } else { -- 1.7.4.msysgit.0
Thanks for this patch - we don't work with Windows much ourselves so this kind of assistance is greatly appreciated! We'll incorporate this in our next release... On Fri Aug 17 18:58:13 2012, NGLENN wrote: Show quoted text
> The current version of this module assumes that Windows users have the
old Show quoted text
> style WordNet files installed, even though the default directory is > labeled as WordNet 3.0. WordNet 3.0 has not been released in a Windows > installer; for research at my university, we normally use Java
libraries, Show quoted text
> etc., and so are not tied to this. We just download the "Unix-like" > distribution and put the files somewhere. They're perfectly usable. > > The problem is in utils/wnDepths.pl. I am including a patch which > discovers the type of files used by looking for "noun.dat" and > "data.noun", etc. and using the one that is found.
patch applied to version 2.07 of WordNet::Similarity, due to be released early October 2015
Installed in version 2.07 of WordNet::Similarity, released today.