-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtraintest.pl
103 lines (76 loc) · 2.59 KB
/
traintest.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# "C:\Users\marko_krema\Documents\Visual Studio 2010\Projects\SentimentTest1\SentimentTest1\inputtmp\inputtmpDocMatrixSorted.txt" "E:\Amazon\m\global.matrix.txt.svmperftfidf.model.txt"
use Config::Simple;
use Getopt::Long;
#$matrix=shift;
#$testmatrix=shift;
#$model=shift;
#$resulteval=shift;
#$algorithm=shift;
$classifier = "svmperftfidf";
$dffilter=0;
$result = GetOptions (
"Features=s" => \$matrix,
"TestFeatures=s" => \$testmatrix,
"model=s" => \$model,
"classifier=s" => \$classifier,
"results=s" => \$resulteval,
"Quick!" => \$quickFlag,
"dffilter=f" => \$dffilter
);
if (length ($classifier)<2) {
$classifier="svmperftfidf";
}
if (length ($model)<2) {
$model="$matrix.$classifier.model.txt";
}
if (length ($result)<2) {
$result="$matrix.$classifier.result.txt";
}
if (length ($resulteval)<2) {
$resulteval="$matrix.$classifier.EVAL.txt";
}
$wordlistfile=$model."WordList.txt";
$SVMfileIDF=$inputfile."SVMLightIDF.txt";
# "C:\Users\marko_krema\Documents\Visual Studio 2010\Projects\SentimentTest1\SentimentTest1\inputtmp\inputtmpDocMatrixSorted.txt" "E:\Amazon\m\global.matrix.txt.svmperftfidf.model.txt"
$inputfile=$matrix;
$SVMfileMAX=$inputfile."SVMLightMAX.txt";
#$wordlistcommand="perl makeWordlistIDFAndMaxFreq.pl $inputfile $wordlistfile";
# $inputcommand = "perl makeSVMLightFile.pl $inputfile $wordlistfile 0 $SVMfileIDF $SVMfileMAX";
$traincommand = "start /wait /b /high perl trainmodel.pl -Features \"$matrix\" -model \"$model\" -classifier $classifier -dffilter $dffilter";
#$modelcommand ="start /wait /realtime /b svm_perf_learn.exe -c 100 -l 10 -w 3 $SVMfileIDF $model ";
$testcommand="start /wait /b /high perl testmodel.pl -Features \"$testmatrix\" -model \"$model\" -results \"$resulteval\"";
#$wordlistresult=`$wordlistcommand`;
print $traincommand . "\n";
$trainresult=runCommand ($traincommand);
print $testcommand . "\n";
#$modelresult=`$modelcommand`;
$testresult=runCommand($testcommand);
#print $testcommand . "\n";
$logfile=$matrix.".TRAINTESTLOG.txt";
open(OUT, ">$logfile") or die "can't open logfile $logfile: $!";
print OUT "$traincommand\n$trainresult\n\n$testcommand\n$testresult\n";
close OUT;
print "Done.\n";
exit;
sub runCommand {
my $command=shift;
my $exe;
my $subst;
my $pl;
my $ret;
if ($command=~/(perl\s+((.*?).pl))/ig) {
$subst=$1;
$pl=$2;
$exe=$3.".exe";
if (!(-e $exe)) {
if (-e "perl2exe\\perl2exe.exe") {
# $ret=`perl2exe\\perl2exe.exe $pl`;
}
}
if (-e $exe) {
$command=~s/$subst/$exe/ig;
}
}
$ret=`$command`;
return $ret;
}