Skip to content

Commit f05d1bc

Browse files
committed
correct an error in ROOT surrounding features
1 parent 907066a commit f05d1bc

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

modules/featmap.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ def give_surrounding_information(sentence, id1, id2):
138138
drpos = "__NULL__"
139139
dlform = "__NULL__"
140140
dlpos = "__NULL__"
141-
142141
if id1 not in [0, 1, len(sentence)]:
143142
hrform = sentence[id1].form
144143
hrpos = sentence[id1].pos
@@ -178,16 +177,16 @@ def fm(infile):
178177
index = 0 # index in featmap
179178

180179
for sentence in sentences(codecs.open(infile, encoding='utf-8')):
181-
182180
for token1 in sentence:
183181
direction = "left"
184182
distance = give_distance(0, token1.id, direction)
185-
hrform, hrpos, hlform, hlpos, drform, drpos, dlform, dlpos = "__NULL__"
183+
hrform = hrpos = hlform = hlpos = drform = drpos = dlform = dlpos = "__NULL__"
186184

187185
# add root features
188186
for feature in give_features("__ROOT__", "__ROOT__", "__ROOT__", token1.form, token1.lemma, token1.pos,
189187
hrform, hrpos, hlform, hlpos, drform, drpos, dlform, dlpos, direction,
190188
distance):
189+
#print feature
191190
if feature not in feat_map:
192191
feat_map[feature] = index
193192
index += 1
@@ -204,6 +203,7 @@ def fm(infile):
204203
for feature in give_features(token1.form, token1.lemma, token1.pos, token2.form, token2.lemma,
205204
token2.pos, hrform, hrpos, hlform, hlpos, drform, drpos, dlform, dlpos,
206205
direction, distance):
206+
#print feature
207207
if feature not in feat_map:
208208
feat_map[feature] = index
209209
index += 1

modules/graphs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __init__(self, tokens, mode="sparse", feat_map=None, weight_vector=None):
5252
if token1.head == 0:
5353
direction = "left"
5454
distance = give_distance(0, token1.id, direction)
55-
hrform, hrpos, hlform, hlpos, drform, drpos, dlform, dlpos = "__NULL__"
55+
hrform = hrpos = hlform = hlpos = drform = drpos = dlform = dlpos = "__NULL__"
5656
new_arc = Arc("sparse", 0, token1.id)
5757
if feat_map is not None:
5858
new_arc.feat_vec = [f for f in (feat_map[feature] for feature in
@@ -91,7 +91,7 @@ def __init__(self, tokens, mode="sparse", feat_map=None, weight_vector=None):
9191

9292
direction = "left"
9393
distance = give_distance(0, token1.id, direction)
94-
hrform, hrpos, hlform, hlpos, drform, drpos, dlform, dlpos = "__NULL__"
94+
hrform = hrpos = hlform = hlpos = drform = drpos = dlform = dlpos = "__NULL__"
9595

9696
if mode == "complete-sparse":
9797
new_arc = Arc("sparse", 0, token1.id)

start-cle.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ python -u dependency-parser.py -test -i $CORPORA/dev/wsj_dev_without_head.conll0
2323
python -u dependency-parser.py -ev -i predicted.conll06 -g $CORPORA/dev/wsj_dev.conll06 -o evaluation_sentence.txt
2424

2525
#evaluate arc based
26-
#./eval07.pl -g $CORPORA/dev/wsj_dev.conll06 -s predicted.conll06 >> evaluation.txt 2>&1
26+
./eval07.pl -g $CORPORA/dev/wsj_dev.conll06 -s predicted.conll06 >> evaluation.txt 2>&1

0 commit comments

Comments
 (0)