-
Notifications
You must be signed in to change notification settings - Fork 150
/
etape.sh
executable file
·277 lines (214 loc) · 9.4 KB
/
etape.sh
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
#!/bin/bash
JCP="bin:../utils/bin:../../git/jsafran/jsafran.jar:../../softs/mallet-2.0.5/dist/mallet.jar:../../softs/mallet-2.0.5/dist/mallet-deps.jar:../../softs/mallet-2.0.5/lib/trove-2.0.2.jar"
if [ "$TERM" = "cygwin" ]; then
echo "transform paths..."
JCP=`echo "$JCP" | sed 's,:,;,g'`
export PATH="$PATH"":../../tools"
else
export PATH=$PATH":../../tools"
fi
echo "extrait les deps (NOM,HEAD) du Gigaword + du train + du test"
LARGECORP=../../git/jsafran/c0b.conll
TRAIN=../../git6/peps/corpus/etape/radios.xml
TEST=../../git6/peps/corpus/etape/devtvs.xml
allens="pers.ind pers.coll loc.add.elec loc.add.phys loc.adm.nat loc.adm.reg loc.adm.sup loc.adm.town loc.fac loc.oro loc.phys.astro loc.phys.geo loc.phys.hydro loc.unk org.adm org.ent amount time.date.abs time.date.rel time.hour.abs time.hour.rel prod.art prod.award prod.doctr prod.fin prod.media prod.object prod.rule prod.serv prod.soft func.coll func.ind event"
#java -Xmx1g -cp "$JCP" PrepHDB -train $LARGECORP $TRAIN $TEST
echo "unsup clustering de E"
# puis je lance ./en.out
# il faut d'abord compiler a la main en.hier dans la machine virtuelle Ubuntu, puis recopier le
# en.c produit dans le rep courant
gcc -g stats.c samplib.c en.c -o en.exe -lm
#./en.exe > en.log
# on a maintenant directement les samples des mots du train et du test
# mais il ne faut pas conserver un seul sample: chaque sample suit p(E)=P(E|sample,reste), donc
# on estime p(E) a partir des samples: p(E=e) = #(E=e)/#(E=*)
# et on veut l'EN la plus probable:
# \hat E = argmax_e P(E=e)
echo "construction des fichiers de train et test pour le CRF"
for en in $allens
do
java -Xmx1g -cp "$JCP" PrepHDB -putclass $TRAIN en.log 0 $en > putclasstrain.log
cp -f groups.$en.tab groups.$en.tab.train
sed 's,trainFile=synfeats0.tab,trainFile=groups.'$en'.tab,g' syn.props > tmp.props
java -Xmx1g -cp detcrf.jar edu.stanford.nlp.ie.crf.CRFClassifier -prop tmp.props
mv kiki.mods en.$en.mods
java -Xmx1g -cp "$JCP" PrepHDB -putclass $TEST en.log 1 $en > putclasstest.log
java -Xmx1g -cp detcrf.jar edu.stanford.nlp.ie.crf.CRFClassifier -loadClassifier en.$en.mods -testFile groups.$en.tab > test.log
cut -f2 test.log > testgold.log
cut -f3 test.log > testrec.log
sed 's,\(.*\)B$,B-\1,g' testgold.log | sed 's,\(.*\)I$,I-\1,g' > testgold.col
sed 's,\(.*\)B$,B-\1,g' testrec.log | sed 's,\(.*\)I$,I-\1,g' > testrec.col
cut -f1 test.log > words.col
awk '
BEGIN {
while ( getline < "words.col" > 0 )
{
f1_co++
f1[f1_co] = $0
}
}
{
print f1[NR]"\t"$0
} ' testgold.col > tty
awk '
BEGIN {
while ( getline < "tty" > 0 )
{
f1_co++
f1[f1_co] = $0
}
}
{
print f1[NR]"\t"$0
} ' testrec.col > ttyy
awk '{if (NF==3) print}' ttyy > oo.log
# paste words.col testgold.col testrec.col | awk '{if (NF==3) print}' > oo.log
./conlleval.pl -d '\t' -o NO < oo.log | grep $en >> res.log
done
exit
deb:
echo "affichage des classes E"
java -Xmx1g -cp "../../git/jsafran/jsafran.jar;bin" PrepHDB -test en.log |& tee verbsuj.classes
echo "construction des fichiers de train et test pour le CRF"
set ens = (pers.ind pers.coll loc.add.elec loc.add.phys loc.adm.nat loc.adm.reg loc.adm.sup loc.adm.town loc.fac loc.oro loc.phys.astro loc.phys.geo loc.phys.hydro loc.unk org.adm org.ent amount time.date.abs time.date.rel time.hour.abs time.hour.rel prod.art prod.award prod.doctr prod.fin prod.media prod.object prod.rule prod.serv prod.soft func.coll func.ind event)
set ens = (pers.ind)
java -Xmx1g -cp "../../git/jsafran/jsafran.jar;bin" PrepHDB -putclass ../../git6/peps/corpus/etape/radios.xml en.log
mv -f groups.* corpus/train/
java -Xmx1g -cp "../../git/jsafran/jsafran.jar;bin" PrepHDB -putclass ../../git6/peps/corpus/etape/devtvs.xml en.log
mv -f groups.* corpus/test/
rm res.log
touch res.log
foreach en ($ens)
sed 's,trainFile=synfeats0.tab,trainFile=corpus/train/groups.'$en'.tab,g' syn.props >! tmp.props
java -Xmx1g -cp detcrf.jar edu.stanford.nlp.ie.crf.CRFClassifier -prop tmp.props
mv kiki.mods en.$en.mods
java -Xmx1g -cp detcrf.jar edu.stanford.nlp.ie.crf.CRFClassifier -loadClassifier en.$en.mods -testFile corpus/test/groups.$en.tab >! test.log
cut -f2 test.log >! testgold.log
cut -f3 test.log >! testrec.log
sed 's,\(.*\)B$,B-\1,g' testgold.log | sed 's,\(.*\)I$,I-\1,g' >! testgold.col
sed 's,\(.*\)B$,B-\1,g' testrec.log | sed 's,\(.*\)I$,I-\1,g' >! testrec.col
cut -f1 test.log >! words.col
paste words.col testgold.col testrec.col | awk '{if (NF==3) print}' >! oo.log
./conlleval.pl -d '\t' -o NO < oo.log | grep $en >> res.log
end
exit
# ##################################################
# deb:
echo "extrait les deps (NOM,HEAD) du Gigaword"
set LARGECORP = ../../git/jsafran/c0b.conll
java -Xmx1g -cp "../../git/jsafran/jsafran.jar;bin" PrepHDB -train $LARGECORP
# deb:
echo "unsup clustering des HEAD"
set d = ""`pwd`
cd $HOME
cp -f $d/enV .
cp -f $d/enO .
./en.out >! $d/en.log
cd $d
deb:
echo "affichage des classes du HEAD"
java -Xmx1g -cp "../../git/jsafran/jsafran.jar;bin" PrepHDB -test en.log |& tee res.classes
exit
# ##################################################
goto unsup
trainCRF:
set ens = (pers.ind pers.coll loc.add.elec loc.add.phys loc.adm.nat loc.adm.reg loc.adm.sup loc.adm.town loc.fac loc.oro loc.phys.astro loc.phys.geo loc.phys.hydro loc.unk org.adm org.ent amount time.date.abs time.date.rel time.hour.abs time.hour.rel prod.art prod.award prod.doctr prod.fin prod.media prod.object prod.rule prod.serv prod.soft func.coll func.ind event)
set ens = (pers.ind)
if (1 == 2) then
# sauve dans les fichiers groups.* tous les mots+POStag avec leur "classe" selon une EN particuliere
pushd .
java -Xmx1g -cp ../../git/jsafran/jsafran.jar jsafran.GroupManager ../../git6/peps/corpus/etape/radios.xml
popd
mv -f groups.* corpus/train/
pushd .
java -Xmx1g -cp ../../git/jsafran/jsafran.jar jsafran.GroupManager ../../git6/peps/corpus/etape/devtvs.xml
popd
mv -f groups.* corpus/test/
else
# idem que ci-dessus sauf que ajoute une col pour les classes
java -Xmx1g -cp "../../git/jsafran/jsafran.jar;bin" PrepHDB -putclass ../../git6/peps/corpus/etape/radios.xml verbsuj.classes
mv -f groups.* corpus/train/
java -Xmx1g -cp "../../git/jsafran/jsafran.jar;bin" PrepHDB -putclass ../../git6/peps/corpus/etape/devtvs.xml verbsuj.classes
mv -f groups.* corpus/test/
endif
rm res.log
touch res.log
foreach en ($ens)
sed 's,trainFile=synfeats0.tab,trainFile=corpus/train/groups.'$en'.tab,g' syn.props >! tmp.props
java -Xmx1g -cp detcrf.jar edu.stanford.nlp.ie.crf.CRFClassifier -prop tmp.props
mv kiki.mods en.$en.mods
java -Xmx1g -cp detcrf.jar edu.stanford.nlp.ie.crf.CRFClassifier -loadClassifier en.$en.mods -testFile corpus/test/groups.$en.tab >! test.log
cut -f2 test.log >! testgold.log
cut -f3 test.log >! testrec.log
sed 's,\(.*\)B$,B-\1,g' testgold.log | sed 's,\(.*\)I$,I-\1,g' >! testgold.col
sed 's,\(.*\)B$,B-\1,g' testrec.log | sed 's,\(.*\)I$,I-\1,g' >! testrec.col
cut -f1 test.log >! words.col
paste words.col testgold.col testrec.col | awk '{if (NF==3) print}' >! oo.log
./conlleval.pl -d '\t' -o NO < oo.log | grep $en >> res.log
end
# java -cp bin ester.Eval test.log NO
# java -Xmx5g -cp detcrf.jar edu.stanford.nlp.ie.crf.CRFClassifier -loadClassifier kicz.mods -testFile $testfile > test.log
# dans git/ponct:
# java -cp dist/ponct.jar tests.Eval
# java -cp "$JCP" etape.CRFEN $*
# java -cp "$JCP" etape.EtapeMaxEnt $*
# java -Xmx1g -cp "$JCP" etape.EtapeLocThenTag $*
exit
giga:
# pour transformer le gigaword French au format JSafran:
set i = 0
while ($i < 341)
java -Xmx1g -cp "../../git/jsafran/jsafran.jar;bin" GigawordIO $i
@ i++
end
# il faut ensuite le segmenter:
java -Xmx1g -cp "../../git/jsafran/jsafran.jar" jsafran.ponctuation.UttSegmenter c$i.xml
mv -f output.xml c$i.xml
# J'ai mis le res dans corpus/Gigaword_French/
# je train le Malt liblinear sur FTB:
java -Xmx1g -jar malt.jar -c ftbmods -l liblinear -i ftbtrain.conll -m learn
# puis je tag le gigaword dans JSafran
# puis je parse le gigaword:
java -Xmx1g -jar malt.jar -c ftbmods -i c0.conll -m parse -o c0b.conll
unsup:
goto tmpx
# puis j'extrais les couples (verbe,sujet)
set LARGECORP = ../../git/jsafran/c0b.conll
# set LARGECORP = synthdata.conll
java -Xmx1g -cp "../../git/jsafran/jsafran.jar;bin" PrepHDB -train $LARGECORP
cd $HOME
cp -f $d/enV .
cp -f $d/enO .
foreach iter (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20)
./en.out >! $d/en.log.$iter
end
tmpx:
# puis j'affiche les classes:
cd $d
rm -f verbsuj.classes
touch verbsuj.classes
foreach iter (1)
java -Xmx1g -cp "../../git/jsafran/jsafran.jar;bin" PrepHDB -test en.log.$iter 3 | grep -e '^classe ' >> verbsuj.classes
end
# reste a moyenner tous les lancers ?? difficile
# rappeler DOM = 03 83 59 20 27
exit
goto trainCRF
# 1er test: j'obtiens des classes de verbes "sémantiques", rassemblant les verbes ayant les memes mots en sujet
# pour avoir des ENs, il faut donner au modele generatif seulement des ENs, et il faut donc les detecter avant.
# Mais on n'est pas oblige d'avoir une bonne detection en F-mesure; il faut une bonne detection en precision !
# 2eme test: modele generique avec seulement les EN... Mais pas forcement mieux, car moins de data, et puis on veut
# regrouper les verbes qui ont les memes types de sujets, pas forcement les memes sujets EN
# analyse des erreurs: il y a peu de classes, et elles sont presque toujours associees a des erreurs de parsing.
# pour qu'elles apportent qqchose, il faut que l'info des classes soit partout !
exit
EN a utiliser:
pers.*
adm.*
loc.*
org.*
amount
time.*
prod.*
func.*
event