From 9fcde1e33e9b2ab006c4271ba5617f17cbc198a9 Mon Sep 17 00:00:00 2001 From: Alexander Gutkin Date: Mon, 16 Dec 2024 15:52:56 +0000 Subject: [PATCH] Throw if the FST arc type cannot be determined. PiperOrigin-RevId: 706708463 --- protoscribe/language/morphology/morphology.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/protoscribe/language/morphology/morphology.py b/protoscribe/language/morphology/morphology.py index 9c59dc1..c646af2 100644 --- a/protoscribe/language/morphology/morphology.py +++ b/protoscribe/language/morphology/morphology.py @@ -344,6 +344,9 @@ def write_rules_to_far( far_path: path to FAR. far_type: type of FAR. is_templates: if true, rules are tuples of tau, lambda, rho. + + Raises: + Value error if the FST arc type cannot be determined. """ if not rules: return @@ -353,6 +356,8 @@ def write_rules_to_far( arc_type = rules[0][0].arc_type() elif isinstance(rules[0], py.Fst): arc_type = rules[0].arc_type() + else: + raise ValueError("Cannot deduce FST arc type from type of the rules!") flattened_rules = [] if is_templates and isinstance(rules[0], tuple): for t, l, r in rules: