-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile.errormining
176 lines (144 loc) · 5.03 KB
/
Makefile.errormining
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
#N=100
N=10
f=3
SADIR=$(ALPINO_HOME)/SuffixArrays
QOPTS=
#QOPTS=-w
Q=$(ALPINO_HOME)/bin/q $(QOPTS)
UNIQ=LANG=POSIX LC_ALL=POSIX sort -u
COUNT=LANG=POSIX LC_ALL=POSIX sort|uniq -c|LANG=POSIX LC_ALL=POSIX sort -nr
WORD_PER_LINE=tr -s '\012\011 ' '\012'
default:
### if you get problems because of some weird very long lines in the
### input, you can try to preprocess your .q files using
### awk 'length($0) < 1000'
%.ok : %.m_ngram %.a_ngram
$(SADIR)/parsability_table.with-binom-test $*.m_ngram $*.a_ngram\
> $*.ok
%.ok_nor : %.m_ngram %.a_ngram
$(SADIR)/parsability_table $*.m_ngram $*.a_ngram \
| LANG=POSIX LC_ALL=POSIX sort -k 1,1n -k2,2rn > $*.ok_nor
%.mistakes:%.q
zcat $*.q | $(Q) -m > $*.mistakes
%.mistakes:%.nq
cat $*.nq | $(Q) -m > $*.mistakes
%.m_ngram: %.m_fsa %.q
zcat $*.q | $(Q) -m |\
$(UNIQ) |\
$(WORD_PER_LINE) |\
$(SADIR)/suffix_array -N -e -d $*.m_fsa -n $(N) -w -G\| -f $(f) -u\
| grep -v ' @ ' > $*.m_ngram
%.a_ngram: %.a_fsa %.q
zcat $*.q | $(Q) -a |\
$(UNIQ) |\
$(WORD_PER_LINE) |\
$(SADIR)/suffix_array -N -e -d $*.a_fsa -n $(N) -w -G\| -f $(f) -u\
| grep -v ' @ ' > $*.a_ngram
%.m_ngram: %.m_fsa %.nq
cat $*.nq | $(Q) -m |\
$(UNIQ) |\
$(WORD_PER_LINE) |\
$(SADIR)/suffix_array -N -e -d $*.m_fsa -n $(N) -w -G\| -f $(f) -u\
| grep -v ' @ ' > $*.m_ngram
%.a_ngram: %.a_fsa %.nq
cat $*.nq | $(Q) -a |\
$(UNIQ) |\
$(WORD_PER_LINE) |\
$(SADIR)/suffix_array -N -e -d $*.a_fsa -n $(N) -w -G\| -f $(f) -u\
| grep -v ' @ ' > $*.a_ngram
## grep -v ' @ '
## because we are not interested in ngrams that cross sentence boundaries
%.a_fsa: %.q
zcat $*.q | $(Q) -a |\
$(WORD_PER_LINE) |\
LANG=POSIX LC_ALL=POSIX sort -u |\
fsa_build -N -o $*.a_fsa
%.m_fsa: %.q
zcat $*.q | $(Q) -m |\
$(WORD_PER_LINE) |\
LANG=POSIX LC_ALL=POSIX sort -u |\
fsa_build -N -o $*.m_fsa
%.a_fsa: %.nq
cat $*.nq | $(Q) -a |\
$(WORD_PER_LINE) |\
LANG=POSIX LC_ALL=POSIX sort -u |\
fsa_build -N -o $*.a_fsa
%.m_fsa: %.nq
cat $*.nq | $(Q) -m |\
$(WORD_PER_LINE) |\
LANG=POSIX LC_ALL=POSIX sort -u |\
fsa_build -N -o $*.m_fsa
.PRECIOUS : %.m_ngram %.m_fsa %.a_ngram %.a_fsa
%.colc : %.a_ngram
cat $*.a_ngram | $(ALPINO_HOME)/Suites/colc -t 0.001 |\
$(ALPINO_HOME)/Suites/remove_smaller |\
LANG=POSIX LC_ALL=POSIX sort -k1,1nr -k2,2nr > $*.colc
LOGS=*.log.gz
cat=zcat
e:
-@$(cat) $(LOGS) | \
grep -v -e '^unknown[|]'\
-e '^guessing[|]'\
-e '^parse: '\
-e '^Lexical analysis: '\
-e '^[*][*][*][*] parsing'\
-e '^[*][*][*][*] parsed'\
-e '^FRAME#'\
-e '^timeout[|]'\
-e '^warning: UNKNOWN'\
-e '^english compound' |\
grep -iw -e killed\
-e warning\
-e 'relocation undefined,'\
-e resource_error\
-e error\
-e segmentation\
-e failure |\
grep -vi -e 'filter_tags removed last tag|'\
-e '^Q#'
logs:
-$(cat) $(LOGS) | $(Q) -c
%.unknowns:%.log.gz
zcat $*.log.gz | grep '^unknown|' | awk -F\| '{ if (NF==4) print $$2 }' |\
$(COUNT) > $*.unknowns
FRAMES=*.frames
assigned_unknowns:
$(MAKE) assigned FILTER="grep -v -e '|normal(' -e '|decap_w_dia|' -e '|w_dia|' -e '|skip|' -e '|robust_skip|' $(assigned)"
assigned_unknowns_with_heur:
$(MAKE) assigned_with_heur FILTER="grep -v -e '|normal(' -e '|decap_w_dia|' -e '|w_dia|' -e '|skip|' -e '|robust_skip|' $(assigned)"
FILTER=cat
assigned:
@zcat $(FRAMES) |\
$(FILTER) |\
awk -F\| '{ printf "%s|%s\n",$$1,$$2 }' |\
$(COUNT) |\
$(ALPINO_HOME)/bin/analyse_unknowns
assigned_with_heur:
@zcat $(FRAMES) |\
$(FILTER) |\
awk -F\| '{ printf "%s|%s|%s\n",$$1,$$2,$$6 }' |\
$(COUNT) |\
$(ALPINO_HOME)/bin/analyse_unknowns
## make tmp log=LOGFILE
## reports statistics based on the log file
log=${shell ls *.log | head -n1}
tmp:
@echo LOG: $(log)
-@grep -i -w -e error -e warning -e ' 0 solution' $(log) | sort | uniq -c
@if grep 'timed out after' $(log)>/dev/null; then echo `grep -c 'timed out after' $(log)` time-outs; fi
@if grep 'out of memory' $(log)>/dev/null; then echo `grep -c 'out of memory' $(log)` times out-of-memory; fi
@grep 'cputime total' $(log) |\
awk ' { N = N+$$3; P = P+1 }\
END { printf "%20s %10.2f after %8.d items\n","total",N/P,P }'
@grep 'Lexical analysis: ' $(log) |\
awk ' { N = N+$$17; P = P+1 }\
END { printf "%20s %10.2f after %8.d items\n",\
"lexical analysis",N/P,P }'
@grep 'Parsed' $(log) | tr -d '()' |\
awk ' { N = N+$$2; P = P+1 }\
END { printf "%20s %10.2f after %8.d items\n",\
"parser",N/P,P }'
@grep 'Found best path:' $(log) | tr -d '()' |\
awk ' { N = N+$$4; P = P+1 }\
END { printf "%20s %10.2f after %8.d items\n",\
"disambiguator",N/P,P }'