-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile.testN
192 lines (157 loc) · 7.42 KB
/
Makefile.testN
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
ifeq "$(shell if [ -r ../Makefile.include ]; then echo yes; fi)" "yes"
include ../Makefile.include
else
ifeq "$(shell if [ -r $(ALPINO_HOME)/Makefile.include ]; then echo yes; fi)" "yes"
include $(ALPINO_HOME)/Makefile.include
endif
endif
SHELL=/bin/bash
default:
@echo "make testN suite=SUITE"
@echo "will run Alpino on the test suite ../Suites/SUITE"
@echo "and will compare the results with the treebank in"
@echo "../Treebank/SUITE/"
@echo "It will find all results, including the best possible result"
@echo "for SUITE would be for the current grammar."
@echo "Default options are specified in this Makefile using"
@echo "variable SUITE_test1_options and SUITE_testN_options"
@echo "You can always specify extra=\"<various alpino options>\" to"
@echo "pass on any non-default options to Alpino."
@echo
@echo
@echo "Each run creates its own working directory"
@echo "for temporary stuff; in addition it appends summarizing"
@echo "statistics to some of the files in a directory dedicated"
@echo "to that suite."
include $(ALPINO_HOME)/Makefile.test
## defaults for testN target
default_testN_options=-testN stop_if_optimal=off user_max=900000 max_sentence_length=25
## defaults per suite for testN target
LassySmall_testN_options=suite_shortest_first=on max_sentence_length=20
novelsample_corrected_testN_options=max_sentence_length=20
cdb_testN_options=suite_shortest_first=on
cgn_exs_testN_options="number_analyses=5000"
ovistrain_testN_options=-flag treebank ../Treebank/ovis
oviswg_testN_options=-flag treebank ../Treebank/ovis
wpspel_testN_options=-flag treebank ../Treebank/wpspel
g_suite_options=robustness=off
h_suite_options=robustness=off
i_suite_options=robustness=off
j_suite_options=robustness=off
job := job${shell echo $$$$}
testN: $(suite).testN
%.testN:%
mkdir -p $*/$(job)
echo "extra=$(extra)" >> $*/bests
-$(MAKE) trees dir=$*/$(job) suite=$*
$(MAKE) testNrest dir=$*/$(job) suite=$*
testNrest:
$(MAKE) -s bestall dir=$(dir) | tee $(dir)/bests
cat $(dir)/bests >> $(shell dirname $(dir)| xargs basename)/bests
grep 'cputime total' $(dir)/log > $(dir)/time
-grep '^T#' $(dir)/log >> $(dir)/time
grep 'BEST SCORE' $(dir)/log > $(dir)/best
$(MAKE) -s --no-print-directory bestall dir=$(dir) \
>> $(dir)/best
$(MAKE) report suite=$(shell dirname $(dir)| xargs basename)
trees:
@echo > $(dir)/times
hostname -f >>$(dir)/times
@echo `date` >> $(dir)/times
@echo `hostname` >> $(dir)/times
@echo "extra=$(extra)" >> $(dir)/times
echo "parser_comparisons." | \
$(ALPINO)\
-flag suite $(suitepath)/$(suite)\
$(default_testN_options)\
$($(suite)_testN_options)\
$(extra) -notk cmdint=off\
2>$(dir)/log | tee -a $(dir)/times
@cat $(dir)/times >> $(suite)/times
## REPORTING STATISTICS ETC
cb: $(JOBS:%/log=%/compare)
COMPARE_C=$(ALPINO_HOME)/compare_c
%/compare: %/log
@echo $(dir $(dir $*))
-@$(COMPARE_C) $(dir $(dir $*))\
<( grep 'BEST SCORE' $< | awk '{ print $$11, $$3, $$15 }' ) \
<( grep 'BEST SCORE' $(dir $(dir $*))/best | awk '{ print $$11, $$3, $$15 }' )
## make bestall dir=DIR
## computes average BEST/WORST/FIRST score, based on DIR/log
## the log file should have been created with end_hook=best_score
bestall:
$(MAKE) bestall0 grep=BEST
$(MAKE) bestall0 grep=FIRST
$(MAKE) bestall0 grep=WORST
@grep 'solution(s)' $(dir)/log |\
awk 'BEGIN {N=0; T=0}\
{N=N+1; T=T+$$2}\
END {printf "%d sentences\n%.2f readings/sentence\n",N,T/N}'
bestall0:
@grep '$(grep) SCORE' $(dir)/log |\
awk '{ PEN=($$7 > $$9 ? $$7 : $$9)-$$5; P=P+PEN; N=N+($$7 > $$9 ? $$7 : $$9); T++; CA=CA+$$3} END { printf "$(grep): ca-score: %.3f\n", 100*(1-P/N); printf "$(grep): per-sent: %.3f\n",CA/T}'
## make report suite=SUITE n=N
## displays summarizing statistics of the last N runs for suite SUITE
n=5
report:
@echo " TotalTime #Parses Parser Time/sent Time/word Edges Mbytes"
@if [ -f $(suite)/times ]; then\
grep '^%XX' $(suite)/times | tail -n $(n); fi
@echo " TREES WORST FIRST BEST"
@if [ -f $(suite)/bests ]; then\
echo "----- recent:";\
paste <(grep 'readings/s' $(suite)/bests | tail -n $(n) | cut -d' ' -f 1)\
<(grep 'WORST: ca-score' $(suite)/bests | tail -n $(n) | cut -d' ' -f 3)\
<(grep 'FIRST: ca-score' $(suite)/bests | tail -n $(n) | cut -d' ' -f 3)\
<(grep 'BEST: ca-score' $(suite)/bests | tail -n $(n) | cut -d' ' -f 3);\
fi
@$(MAKE) -s reportcurrentbest
@if [ -f $(suite)/scores ]; then\
echo "----- recent:";\
grep ca-score $(suite)/scores | tail -n $(n); fi
reportcurrentbest:
@if [ -f $(suite)/best ]; then\
trees=`tail $(suite)/best | grep 'readings/sentence'|awk '{ print $$1}'`;\
best=`tail $(suite)/best | grep '^BEST: ca-score'|awk '{ print $$3}'`;\
first=`tail $(suite)/best | grep '^FIRST: ca-score'|awk '{ print $$3}'`;\
worst=`tail $(suite)/best | grep '^WORST: ca-score'|awk '{ print $$3}'`;\
echo "----- expected:";\
echo "$$trees $$worst $$first $$best $(suite)";\
fi
tests: j_suite.testN i_suite.testN h_suite.testN g_suite.testN leuven_yellow_pages.testN lot_test_suite1.testN \
cgn_exs.testN qa.testN extra.testN cdb.testN wpspel.testN LassySmall.testN lassy-doc.testN\
novelsample_corrected.testN eans.testN Titaantjes.testN ovistrain.testN
shs: i_suite.testN h_suite.testN g_suite.testN j_suite.testN
shs_rest: leuven_yellow_pages.testN lot_test_suite1.testN \
cgn_exs.testN qa.testN extra.testN lassy-doc.testN novelsample_corrected.testN eans.testN \
cdb.testN wpspel.testN LassySmall.testN Titaantjes.testN
## all but cdb LassySmall
shorts: j_suite.testN i_suite.testN h_suite.testN g_suite.testN leuven_yellow_pages.testN lot_test_suite1.testN \
cgn_exs.testN qa.testN extra.testN wpspel.testN lassy-doc.testN\
novelsample_corrected.testN eans.testN Titaantjes.testN ovistrain.testN
longs: cdb.testN LassySmall.testN
SCORES=$(sort $(wildcard */*/bests))
bf:
ifeq ($(strip $(SCORES)),)
@echo "bf: nothing to do"
else
@echo " BEST-CA #PARSES SUITE"
@echo " NEW OLD NEW OLD"
@$(MAKE) -s $(SCORES:%bests=%bf) |\
awk '{ G=" ";\
if ($$1>$$2) {G="!"};\
if ($$2>$$1) {G="?"};\
printf "%s %7.3f %7.3f %8.2f %8.2f %s %s\n",\
G,$$1,$$2,$$3,$$4,$$5,$$6;\
N=N+1; A=A+$$1; B=B+$$2; C=C+$$3; D=D+$$4 }\
END {printf "\n %7.3f %7.3f %8.2f %8.2f mean\n",\
A/N,B/N,C/N,D/N}'
endif
%/bf:%/bests
@echo `grep 'BEST: ca-score' $< | awk '{ print $$3 }' `" "`if [ -f $(dir $(dir $*))/best ]; then grep 'BEST: ca-score' $(dir $(dir $*))/best | tail -n 2 | head -n 1 | awk '{ print $$3 }'; fi`" "`grep readings/sentence $< | awk '{ print $$1 }'`" "`if [ -f $(dir $(dir $*))/best ]; then grep 'readings/sentence' $(dir $(dir $*))/best | tail -n 2 |head -n 1 | awk '{ print $$1 }'; fi`" "$(dir $(dir $*))" "`grep extra= $(dir $(dir $*))/times |tail -n 1|sed -e 's/extra=//' | tr ' ' ',' `
ORDERED=-rt
errors: cdb.err LassySmall.err
%.err: %.errors
@for file in $*/job*/log;\
do $(ALPINO_HOME)/compare_errors.py <(grep '^BEST SCORE' $$file | awk '{ print $$3, $$11 }') $*.errors;\
done