Skip to content

Commit 73f2a8e

Browse files
committed
Fix error in Graph when called during evaluation
1 parent 5473abd commit 73f2a8e

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

modules/graphs.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ def __init__(self, tokens, mode="sparse", feat_map=None, weight_vector=None):
5656
distance = give_distance(0, token1.id, direction)
5757

5858
new_arc = Arc("sparse", 0, token1.id)
59-
new_arc.feat_vec = [f for f in (feat_map[feature] for feature in
60-
give_features("__ROOT__", "__ROOT__", "__ROOT__", token1.form,
61-
token1.lemma, token1.pos, token1.rel, direction,
62-
distance) if feature in feat_map)]
59+
if feat_map is not None:
60+
new_arc.feat_vec = [f for f in (feat_map[feature] for feature in
61+
give_features("__ROOT__", "__ROOT__", "__ROOT__", token1.form,
62+
token1.lemma, token1.pos, token1.rel, direction,
63+
distance) if feature in feat_map)]
6364
self.heads[0].append(new_arc)
6465

6566
# add every other arc
@@ -69,10 +70,12 @@ def __init__(self, tokens, mode="sparse", feat_map=None, weight_vector=None):
6970
distance = give_distance(token1.id, token2.id, direction)
7071

7172
new_arc = Arc("sparse", token1.id, token2.id)
72-
new_arc.feat_vec = [f for f in (feat_map[feature] for feature in
73-
give_features(token1.form, token1.lemma, token1.pos, token2.form,
74-
token2.lemma, token2.pos, token2.rel, direction,
75-
distance) if feature in feat_map)]
73+
if feat_map is not None:
74+
new_arc.feat_vec = [f for f in (feat_map[feature] for feature in
75+
give_features(token1.form, token1.lemma, token1.pos,
76+
token2.form,
77+
token2.lemma, token2.pos, token2.rel, direction,
78+
distance) if feature in feat_map)]
7679
dependents.append(new_arc)
7780
if dependents:
7881
self.heads[token1.id] = dependents

start-cle.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ PREDICTIONS="predictions"
99
EVALUATIONS="evaluations"
1010

1111
#train (on small set)
12-
python -u dependency-parser.py -train -i $CORPORA/train/wsj_train.first-5k.conll06 -m model -e 10
12+
#python -u dependency-parser.py -train -i $CORPORA/train/wsj_train.first-5k.conll06 -m model -e 10
1313
#python -u dependency-parser.py -train -i $CORPORA/train/wsj_train_super_small.conll06 -m model -e 1
1414
#python -u dependency-parser.py -train -i $CORPORA/train/wsj_train_hyper_small.conll06 -m model -e 1
1515

1616
#train
1717
#python -u dependency-parser.py -train -i $CORPORA/train/wsj_train.conll06 -m $MODELS/model -e 2 -decrease-alpha
1818

1919
#test
20-
python -u dependency-parser.py -test -i $CORPORA/dev/wsj_dev_without_head.conll06 -m model -o predicted.conll06
20+
#python -u dependency-parser.py -test -i $CORPORA/dev/wsj_dev_without_head.conll06 -m model -o predicted.conll06
2121

2222
#evaluate sentence based
2323
python -u dependency-parser.py -ev -i predicted.conll06 -g $CORPORA/dev/wsj_dev.conll06 -o evaluation_sentence.txt

0 commit comments

Comments
 (0)