-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtest_sm_1.test
executable file
·71 lines (57 loc) · 2.11 KB
/
test_sm_1.test
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
#!/bin/sh
##################################################################
# Variables
TYPE='--type=semim'
INPUT="${TOP_SRCDIR}/tests/test_sm_1.input"
MODEL="-m ${TOP_BUILD_PREFIX}tests/test_sm_1.model"
OUTPUT_1_1="${TOP_BUILD_PREFIX}tests/test_sm_1_1.output"
EXPECTED_1_1="${TOP_SRCDIR}/tests/test_sm_1_1.expected"
OUTPUT_1_3="${TOP_BUILD_PREFIX}tests/test_sm_1_3.output"
EXPECTED_1_3="${TOP_SRCDIR}/tests/test_sm_1_3.expected"
OUTPUT_1_5="${TOP_BUILD_PREFIX}tests/test_sm_1_5.output"
EXPECTED_1_5="${TOP_SRCDIR}/tests/test_sm_1_5.expected"
##################################################################
# Methods
run_test()
(
if test $# -ne 6; then
echo 'Incorrect number of arguments specified for test function.' >&2
echo 'Bail out!'
exit 1
fi
test_i="$1"
model_name="$2"
order="$3"
seg_len="$4"
output="$5"
expected="$6"
# test convergence
${TOP_BUILD_PREFIX}frontend/crfsuite learn ${TYPE} -p feature.max_order=${order} \
-p feature.max_seg_len=${seg_len} ${MODEL} ${INPUT}
if test $? -eq 0; then
echo "ok ${test_i} # ${model_name} model has converged"
else
echo "not ok ${test_i} # ${model_name} model has not converged (exit code $?)"
fi
# test results
test_i=$((test_i+1))
${TOP_BUILD_PREFIX}frontend/crfsuite tag ${TYPE} ${MODEL} ${INPUT} > "${output}"
diff -q "${output}" "${expected}" &> /dev/null
if test $? -eq 0; then
echo "ok ${test_i} # ${model_name} model predicted tags correctly"
else
echo "not ok ${test_i} # ${model_name} model predicted tags incorrectly"
fi
)
##################################################################
# Header
echo '1..6'
##################################################################
# Test 1, 2
run_test 1 '1-st order linear-chain' 1 1 "${OUTPUT_1_1}" "${EXPECTED_1_1}"
##################################################################
# Test 3, 4
run_test 3 '5-th order semi-markov' 5 -1 "${OUTPUT_1_3}" "${EXPECTED_1_3}"
##################################################################
# Test 5, 6
run_test 5 '5-th order linear-chain' 5 1 "${OUTPUT_1_5}" "${EXPECTED_1_5}"