File: SFX

package info (click to toggle)
dbacl 1.12-2.2
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 3,740 kB
  • sloc: ansic: 16,594; sh: 7,963; makefile: 244; yacc: 167; lex: 78; awk: 24; xml: 17; perl: 8
file content (132 lines) | stat: -rw-r--r-- 4,015 bytes parent folder | download | duplicates (5)
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/sh

# This is a self extracting archive designed for the TREC 2005 spam
# filtering track. It deletes several directories and files in the current 
# working dir, which will then be replaced.
#
# We construct the archive by cat SFX dbacl-xxx.tar.gz > dbacl-xxx.sfx
#
# This script accepts one optional command line argument. If present,
# we check whether a corresponding file named OPTIONS.zzz is present
# in the TREC subdirectory, where zzz is the argument value. This
# file is used to overwrite the OPTIONS file containing the switches
# for the simulation. In this way, we can self-install several
# variations of the classifier.
#
# If no options are given, we use OPTIONS.default if it exists in the 
# current working directory. Each time a command line option is presented,
# the OPTIONS.default file is (re)created automatically from that argument.
#
# If no options are give, and no OPTIONS.default exists in the current
# working directory, then we present a help message and a list of 
# possible OPTIONS.
#
#

NAME=`basename $0 .TREC.sfx.sh`
W=$PWD
SKIP=`grep -a -n -m 1 '^__ARCHIVE_FOLLOWS__' $0 | sed 's/:.*//'`

function usage() {
	echo "Usage: $0 [XXX]"
	echo ""
	echo "Welcome to the dbacl TREC/spam evaluation package."
	echo "This script unpacks automatically into the current directory"
	echo "a fresh copy of all the files and programs expected by the"
	echo "TREC 2005 spamjig (spam filter evaluation system), such as the"
	echo "initialize script."
	echo ""
	echo "If you are seeing this message, then you have yet to select"
	echo "which algorithms and runtime options are to be tested in this"
	echo "instance of the spamjig test run. All you have to do is rerun"
	echo "the present script with the appropriate value of XXX chosen"
	echo "from the list below. This will copy a file named OPTIONS.default"
	echo "into the current directory which will lock your chosen options"
	echo "for all required scripts."
	echo ""
	echo "You can change options later by rerunning this script with"
	echo "another value of XXX, or even edit the OPTIONS.default file"
	echo "directly if you know what you are doing."
	echo ""
	echo "Possible values for XXX:"

	tail +`expr $SKIP + 1` $0 | gunzip -c | tar t | grep 'TREC/OPTIONS.' | sed 's/^.*OPTIONS.//'

}

OPTARG=$1
if [ -z $OPTARG ]; then
	OPTARG=default
	if [ ! -e "$W/OPTIONS.$OPTARG" ]; then
		usage
		exit 1
	fi
fi

echo ""
echo "Installing $NAME - please wait...."
echo ""

rm -rf "$W/$NAME"
tail +`expr $SKIP + 1` $0 | gunzip -c | tar x

if [ -d "$W/$NAME" ]; then
	if [ -n $OPTARG ]; then
		if [ -e "$W/$NAME/TREC/OPTIONS.$OPTARG" ]; then
			cat "$W/$NAME/TREC/OPTIONS.$OPTARG" > "$W/$NAME/TREC/OPTIONS"
			cp -f "$W/$NAME/TREC/OPTIONS.$OPTARG"  "$W/OPTIONS.default"
		else
			echo "No OPTIONS.$OPTARG in $W/$NAME/TREC, trying working directory..."
			if [ -e "$W/OPTIONS.$OPTARG" ]; then
			    echo "Found $W/OPTIONS.$OPTARG."
			    cat "$W/OPTIONS.$OPTARG" > "$W/$NAME/TREC/OPTIONS"
			else
			    echo "Could not find $W/OPTIONS.$OPTARG, using defaults."
			fi
			
		fi
	fi

	echo "Installing these options:"
	echo "---------"
	cat $W/$NAME/TREC/OPTIONS
	echo "---------"

	cd "$W/$NAME"
	./configure "--prefix=$W" && make && make check && make install-strip
	if [ -x "$W/bin/dbacl" ]; then

	    for f in initialize finalize classify train ; do
		rm -f "$W/$f" && cp "$W/share/dbacl/TREC/$f" "$W/$f"
		chmod u+x "$W/$f"
	    done

	else
	    echo "Installation did NOT complete successfully."
	    exit 1
	fi

	cd "$W"
	rm -rf "$W/db" && mkdir "$W/db"
	rm -f "$W/stderr.log"
	"$W/train" ham "$W/share/dbacl/TREC/basic-email"
	"$W/train" spam "$W/share/dbacl/TREC/basic-email"

	if ! cmp -s "$W/stderr.log" "$W/share/dbacl/TREC/verify-stderr" ; then
	    echo "Basic learning failed. See stderr.log below:"
	    echo "---"
	    cat "$W/stderr.log"
	    exit 1
	fi

else
	echo "There was a problem while extracting the archive."
	exit 1
fi

echo "Done!"

exit 0

# no extra characters allowed after this line!
__ARCHIVE_FOLLOWS__