~ubuntu-branches/ubuntu/precise/dbacl/precise

« back to all changes in this revision

Viewing changes to src/tests/score-1.shin

  • Committer: Bazaar Package Importer
  • Author(s): Clint Adams
  • Date: 2005-05-07 12:59:53 UTC
  • Revision ID: james.westby@ubuntu.com-20050507125953-xzy2bwkb2qamglwm
Tags: upstream-1.9
ImportĀ upstreamĀ versionĀ 1.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# verify that empirical divergence is zero for a single email.
 
3
PATH=/bin:/usr/bin
 
4
DBACL=$TESTBIN/dbacl
 
5
 
 
6
prerequisite_command() {
 
7
    type $2 2>&1 > /dev/null
 
8
    if [ 0 -ne $? ]; then
 
9
        echo "$1: $2 not found, test will be skipped"
 
10
        exit 77
 
11
    fi
 
12
}
 
13
 
 
14
prerequisite_command $0 grep
 
15
prerequisite_command $0 awk
 
16
prerequisite_command $0 tr
 
17
 
 
18
DBACL_PATH="`pwd`/`basename $0 .sh`_`date +"%Y%m%dT%H%M%S"`"
 
19
export DBACL_PATH
 
20
 
 
21
mkdir "$DBACL_PATH"
 
22
 
 
23
cat sample.spam-2 \
 
24
    | $DBACL -0 -l dummy -X -d -T email \
 
25
    | grep '# shannon' \
 
26
    | awk '{print $5/log(2)}' \
 
27
    | tr '\n' ' ' \
 
28
    > "$DBACL_PATH/out1"
 
29
 
 
30
cat sample.spam-2 \
 
31
    | $DBACL -c dummy -vX \
 
32
    | awk '{print $3, $5}' \
 
33
    > "$DBACL_PATH/out2"
 
34
 
 
35
echo "`cat \"$DBACL_PATH/out1\"` `cat \"$DBACL_PATH/out2\"`" \
 
36
    | awk '
 
37
function abs(x) { return (x >= 0) ? x : -x }
 
38
{
 
39
    # error in divergence can be up to 15% of shannon entropy estimate
 
40
    # must invert exit value
 
41
    exit !( abs($1 - $2) < (0.15) * ($3) ) 
 
42
}'
 
43
 
 
44
RESULT=$?
 
45
rm -rf "$DBACL_PATH"
 
46
 
 
47
exit $RESULT
 
 
b'\\ No newline at end of file'