4

I want to analyse my summaries using ROUGE. So far i have written a perl script to run ROUGE on the command line, this is what I have so far:

#!/usr/bin/perl

use warnings;
use Cwd;
$curdir=getcwd;
$ROUGE="/ROUGE-1.5.5.pl";
chdir("sample-test");
$cmd="$ROUGE -e /data -c 95 -2 -1 -U -r 1000 -n 4 -w 1.2 -a DUC2002ROUGE.in.26.spl.xm> /sample-output/salam.out";
print $cmd,"\n";
system($cmd);
chdir($curdir);

However I get this error:

the system can't find the specified path

jksnw
  • 648
  • 1
  • 7
  • 19

7 Answers7

5

the system can't find the specified path

You have wrong path to your script, /ROUGE-1.5.5.pl does not exists, and thus shell invoked by system() is complaining.

mpapec
  • 50,217
  • 8
  • 67
  • 127
5

The problem is that /ROUGE-1.5.5.pl is an absolute file path that says the file is in the root directory. You say it is in the same directory as the running Perl program so you need ./ROUGE-1.5.5.pl or just ROUGE-1.5.5.pl

This program fixes the problem and plugs a few holes. I have used the abs_path function from Cwd to convert the program, data, input and output names to absolute paths; that performs an implicit check that the files exist, and lets me avoid the chdir which just confuses things. I've also added a crude diagnostic to system to give some hint why it failed

#!/usr/bin/perl

use strict;
use warnings 'all';

use Cwd qw/ getcwd abs_path /;

my $ROUGE  = abs_path('ROUGE-1.5.5.pl');

my $data   = abs_path('data');
my $input  = abs_path('sample-test/DUC2002ROUGE.in.26.spl.xm');
my $output = abs_path('sample-output/salam.out');

my $cmd = qq{"$ROUGE" -e "$data" -c 95 -2 -1 -U -r 1000 -n 4 -w 1.2 -a "$input" > "$output"};
print $cmd, "\n";

system($cmd) == 0 or die qq{system() failed: $?};
Borodin
  • 126,100
  • 9
  • 70
  • 144
2

I believe I have the answer if you want the ROUGE output to be stored in a file rather than printed to the command line or terminal.

You don't need a perl script, you can run ROUGE from the command line. To output to a file add > results.txt to the end of the command.

Running something like this will output to the command line:

perl ROUGE-1.5.5.pl -e data -n 4 -w 1.2 -m  -2 4 -u -c 95 -r 1000 -f A -p 0.5 -t 0 -a -d settings.xml

Whereas this will output to a file called results.txt:

perl ROUGE-1.5.5.pl -e data -n 4 -w 1.2 -m  -2 4 -u -c 95 -r 1000 -f A -p 0.5 -t 0 -a -d settings.xml > results.txt

This question helped me: How to redirect console output to a text file

Community
  • 1
  • 1
jksnw
  • 648
  • 1
  • 7
  • 19
2

You had a few wrong file paths and a couple of typos but this works:

#!/usr/bin/perl

use warnings;
use Cwd;
$curdir=getcwd;
$ROUGE="../ROUGE-1.5.5.pl";
chdir("sample-test");
$cmd="$ROUGE -e ../data -c 95 -2 -1 -U -r 1000 -n 4 -w 1.2 -a DUC2002-ROUGE.in.26.spl.xml > ../sample-output/salam.out";
print $cmd,"\n";
system($cmd);
chdir($curdir);

But why use a perl to script to run ROUGE when you could just type this into the command line:

perl ROUGE-1.5.5.pl -e data -c 95 -2 -1 -U -r 1000 -n 4 -w 1.2 -a sample-test/DUC2002-ROUGE.in.26.spl.xml > sample-output/salam.out

jksnw
  • 648
  • 1
  • 7
  • 19
1

I agree with the other answers regarding absolute vs. relative paths. I also agree with the issue of why use Perl when you can do this as a simple command line argument. However, I'm going to turn that around and say, if you are going to use Perl to do this, make it an opportunity to document what you're doing to make it easier to tweak in the future, something like:

use strict;
use warnings;
use Cwd;

my $curdir = getcwd;

use constant ROUGE => '../ROUGE-1.5.5.pl';

my @OPTIONS = ('-2', '-1', '-U', # use skip-bigrams and compute unigram scores (not sure -1 is valid)
    '-e' => '../data', # data directory
    '-c' => 95, # confidence interval (default)
    '-r' => 1000, # sampling points (default)
    '-n' => 4, # max-ngram length
    '-w' => 1.2, # LCS weight
    '-a' => 'DUC2002-ROUGE.in.26.spl.xml'
);

if (chdir("sample-test")) {

    my $cmd = join(" ", ROUGE, @OPTIONS, "> ../sample-output/salam.out");
    print STDERR $cmd, "\n";
    system($cmd);

    chdir($curdir);
}
cdlane
  • 40,441
  • 5
  • 32
  • 81
-1

I think you want to evaluate the summerization using rouge in windows.I recommend you to use an ubuntu version of linux and install the rouge and use this command to get your output:

I mean save this file as a perl file and execute this file in terminal of linux

 #!/usr/bin/perl -w
use Cwd;
$curdir=getcwd;
$ROUGE="../ROUGE-1.5.5.pl";
chdir("sample-test");
$cmd="$ROUGE -e ../data -c 95 -2 -1 -U -r 1000 -n 4 -w 1.2 -a ROUGE-test.xml > ../sample-output/ROUGE-test-c95-2-1-U-r1000-n4-w1.2-a.out";
print $cmd,"\n";
system($cmd);
$cmd="$ROUGE -e ../data -c 95 -2 -1 -U -r 1000 -n 4 -w 1.2 -a -m ROUGE-test.xml > ../sample-output/ROUGE-test-c95-2-1-U-r1000-n4-w1.2-a-m.out";
print $cmd,"\n";
system($cmd);
$cmd="$ROUGE -e ../data -c 95 -2 -1 -U -r 1000 -n 4 -w 1.2 -a -m -s ROUGE-test.xml > ../sample-output/ROUGE-test-c95-2-1-U-r1000-n4-w1.2-a-m-s.out";
print $cmd,"\n";
system($cmd);
$cmd="$ROUGE -e ../data -c 95 -2 -1 -U -r 1000 -n 4 -w 1.2 -l 10 -a ROUGE-test.xml > ../sample-output/ROUGE-test-c95-2-1-U-r1000-n4-w1.2-l10-a.out";
print $cmd,"\n";
system($cmd);
$cmd="$ROUGE -e ../data -c 95 -2 -1 -U -r 1000 -n 4 -w 1.2 -l 10 -a -m ROUGE-test.xml > ../sample-output/ROUGE-test-c95-2-1-U-r1000-n4-w1.2-l10-a-m.out";
print $cmd,"\n";
system($cmd);
$cmd="$ROUGE -e ../data -c 95 -2 -1 -U -r 1000 -n 4 -w 1.2 -l 10 -a -m -s ROUGE-test.xml > ../sample-output/ROUGE-test-c95-2-1-U-r1000-n4-w1.2-l10-a-m-s.out";
print $cmd,"\n";
system($cmd);
$cmd="$ROUGE -e ../data -c 95 -2 -1 -U -r 1000 -n 4 -w 1.2 -b 75 -a ROUGE-test.xml > ../sample-output/ROUGE-test-c95-2-1-U-r1000-n4-w1.2-b75-a.out";
print $cmd,"\n";
system($cmd);
$cmd="$ROUGE -e ../data -c 95 -2 -1 -U -r 1000 -n 4 -w 1.2 -b 75 -a -m ROUGE-test.xml > ../sample-output/ROUGE-test-c95-2-1-U-r1000-n4-w1.2-b75-a-m.out";
print $cmd,"\n";
system($cmd);
$cmd="$ROUGE -e ../data -c 95 -2 -1 -U -r 1000 -n 4 -w 1.2 -b 75 -a -m -s ROUGE-test.xml > ../sample-output/ROUGE-test-c95-2-1-U-r1000-n4-w1.2-b75-a-m-s.out";
print $cmd,"\n";
system($cmd);
$cmd="$ROUGE -e ../data -3 HM -z SIMPLE DUC2002-BE-F.in.26.lst 26 > ../sample-output/DUC2002-BE-F.in.26.lst.out";
print $cmd,"\n";
system($cmd);
$cmd="$ROUGE -e ../data -3 HM DUC2002-BE-F.in.26.simple.xml 26 > ../sample-output/DUC2002-BE-F.in.26.simple.out";
print $cmd,"\n";
system($cmd);
$cmd="$ROUGE -e ../data -3 HM -z SIMPLE DUC2002-BE-L.in.26.lst 26 > ../sample-output/DUC2002-BE-L.in.26.lst.out";
print $cmd,"\n";
system($cmd);
$cmd="$ROUGE -e ../data -3 HM DUC2002-BE-L.in.26.simple.xml 26 > ../sample-output/DUC2002-BE-L.in.26.simple.out";
print $cmd,"\n";
system($cmd);
$cmd="$ROUGE -e ../data -n 4 -z SPL DUC2002-ROUGE.in.26.spl.lst 26 > ../sample-output/DUC2002-ROUGE.in.26.spl.lst.out";
print $cmd,"\n";
system($cmd);
$cmd="$ROUGE -e ../data -n 4 DUC2002-ROUGE.in.26.spl.xml 26 > ../sample-output/DUC2002-ROUGE.in.26.spl.out";
print $cmd,"\n";
system($cmd);
chdir($curdir);
Ehsan Akbar
  • 6,977
  • 19
  • 96
  • 180
  • Thank you ,i finally install the rouge on linux .and i can run that. –  Jan 23 '16 at 05:54
-4
  1. install perl http://www.activestate.com/activeperl

  2. run from dos command if on windows

    perl perlscript.pl

ikegami
  • 367,544
  • 15
  • 269
  • 518
lordkain
  • 3,061
  • 1
  • 13
  • 18
  • Why the -1, the question was incapeble to run the program. – lordkain Oct 14 '13 at 02:57
  • 1
    I didn't downvote you, but the error message quoted in the question was emitted when the script ran - so the user must have had Perl installed already. Also I'd recommend Strawberry Perl over ActivePerl. – Grant McLean Jan 19 '16 at 03:46