From 839e5038b70ea16e1d55bf3a02a58a832ab36ae9 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 23 Jun 2015 00:01:55 +0200 Subject: [PATCH] * Raise exception on non-projective input --- bin/parser/train.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/parser/train.py b/bin/parser/train.py index c0834c45c..e3de03dcf 100755 --- a/bin/parser/train.py +++ b/bin/parser/train.py @@ -130,8 +130,13 @@ def train(Language, gold_tuples, model_dir, n_iter=15, feat_set=u'basic', raw_text = add_noise(raw_text, corruption_level) tokens = nlp.tokenizer(raw_text) nlp.tagger(tokens) - gold = GoldParse(tokens, annot_tuples, make_projective=True) - loss += nlp.parser.train(tokens, gold) + gold = GoldParse(tokens, annot_tuples, make_projective=False) + if not gold.is_projective: + raise Exception( + "Non-projective sentence in training, after we should " + "have enforced projectivity: %s" % annot_tuples + ) + loss += nlp.parser.train(tokens, gold) nlp.entity.train(tokens, gold) nlp.tagger.train(tokens, gold.tags)