How do I access the perl program to write it to a file?

I want to analyze my resumes 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 cannot find the specified path

+4
source share
7 answers

I think you want to appreciate flying using rouge in windows. I recommend that you use the linux version ubuntuand install rouge and use this command to get your output:

I want to save this file as perl file and execute this file in linux terminal

 #!/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);
-1
source

the system cannot find the specified path

script, /ROUGE-1.5.5.pl , , system(), .

+5

, /ROUGE-1.5.5.pl - , , . , , Perl, ./ROUGE-1.5.5.pl ROUGE-1.5.5.pl

. abs_path Cwd , , ; , , chdir, . system, ,

#!/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: $?};
+5

, , , ROUGE , .

perl script, ROUGE . > 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:

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

:

+2

, :

#!/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);

perl script ROUGE, :

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

+2

I agree with other answers regarding absolute or relative paths. I also agree with the problem of using Perl when you can do this as a simple command line argument. However, I am going to rotate this and say if you are going to use Perl for this, make it possible to document what you are doing to simplify the configuration in the future, for example:

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);
}
+1
source
-4
source

All Articles