From 577983427e7dce0179fe515860e316c4c00efd6f Mon Sep 17 00:00:00 2001 From: Ozbolt Menegatti Date: Mon, 1 Jul 2019 17:22:30 +0200 Subject: [PATCH] Better error reporting in parsing syntactic structures --- src/syntactic_structure.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/syntactic_structure.py b/src/syntactic_structure.py index b90d7a9..b7b9dd5 100644 --- a/src/syntactic_structure.py +++ b/src/syntactic_structure.py @@ -86,7 +86,10 @@ class SyntacticStructure: for c in self.components: if c.idx == idx: return c - raise RuntimeError("Unknown component id: {}".format(idx)) + + cs = [c.idx for c in self.components] + msg = "Structure id={} has components: {}, but no component: {}".format(self.id, cs, (idx,)) + raise RuntimeError(msg) def match(self, word): matches = self.components[0].match(word)