echo
echo Testing the program 'discrim'
echo Making datafiles...

rm test_dirfile1 >& /dev/null
cat > test_dirfile1 << EOF1
1 diabetes 2.0
1 mellitus 1.0
1 number 2.0
2 number 1.0
2 zero 4.0
2 math 2.0
3 math 1.0
3 diabetes 1.0
4 rough 1.0
4 sets 1.0
4 logic 1.0
5 algebra 2.0
5 alg 2.0
6 math 2.0
7 geometry 3.0
7 cosine 1.0
8 arts 1.0
8 graphics 2.0
8 painting 2.0
9 metals 1.0
9 fibres 2.0
9 architecture 1.0
10 disease 1.0
10 diabetes 1.0
10 therapy 2.0
10 knowledge 1.0
11 diabetes 1.0
11 mellitus 2.0
12 therapy 1.0
12 medicine 2.0
13 math 3.0
13 coordinate 1.0
14 coordinate 2.0
14 geometry 2.0
14 algebra 1.0
15 logic 5.0
15 vectors 1.0
15 predicates 2.0
15 first-order 1.0

EOF1

rm test_dirfile2 >& /dev/null
cat > test_dirfile2 << EOF2
# test
#nog een test

1 2.0 diabetes
1 1.0 mellitus
1 2.0 number
2 1.0 number
2 4.0 zero
2 2.0 math
3 1.0 math
3 1.0 diabetes
4 1.0 rough
4 1.0 sets
4 1.0 logic
5 2.0 algebra
5 2.0 alg
6 2.0 math
7 3.0 geometry
7 1.0 cosine
8 1.0 arts
8 2.0 graphics
8 2.0 painting
9 1.0 metals
9 2.0 fibres
9 1.0 architecture
10 1.0 disease
10 1.0 diabetes
10 2.0 therapy
10 1.0 knowledge
11 1.0 diabetes
11 2.0 mellitus
12 1.0 therapy
12 2.0 medicine
13 3.0 math
13 1.0 coordinate
14 2.0 coordinate
14 2.0 geometry
14 1.0 algebra
15 5.0 logic
15 1.0 vectors
15 2.0 predicates
15 1.0 first-order
  

EOF2


rm test_disc_result >& /dev/null
cat > test_discresult << EOF3
# words in centroid: 26, docs: 15
# baseline 0.358314
diabetes -0.011956
mellitus 0.004183
number 0.002421
zero 0.016092
math -0.044309
rough 0.002146
sets 0.002146
logic -0.003664
algebra -0.002831
alg 0.000662
geometry -0.008811
cosine 0.000479
arts 0.000001
graphics -0.000319
painting -0.000319
metals -0.000177
fibres -0.001485
architecture -0.000177
disease 0.000671
therapy -0.001922
knowledge 0.000671
medicine 0.002401
coordinate 0.002178
vectors 0.000410
predicates 0.001641
first-order 0.000410
EOF3

rm test_discresult2 >& /dev/null
cat > test_discresult2 << EOF4
# words in centroid: 26, docs: 15
# baseline 1.200346
diabetes -0.012179
mellitus 0.004717
number 0.002694
zero 0.018207
math -0.048462
rough 0.002299
sets 0.002299
logic -0.001432
algebra -0.002430
alg 0.000940
geometry -0.007636
cosine 0.000546
arts 0.000070
graphics -0.000036
painting -0.000036
metals -0.000106
fibres -0.001189
architecture -0.000106
disease 0.000749
therapy -0.001398
knowledge 0.000749
medicine 0.002721
coordinate 0.002310
vectors 0.000461
predicates 0.001848
first-order 0.000461
EOF4

echo "testing cosine..."
discrim -m0 test_dirfile1 | diff test_discresult - 
echo "testing angle..."
discrim -m1 test_dirfile2 | diff test_discresult2 - 

echo "If the two lines above read 'testing (method)...' everything is in order..."


rm test_dirfile1 >& /dev/null
rm test_dirfile2 >& /dev/null
rm test_discresult >& /dev/null
rm test_discresult2 >& /dev/null

echo