Skip to content

Commit

Permalink
Throw if the FST arc type cannot be determined.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 706708463
  • Loading branch information
agutkin committed Dec 16, 2024
1 parent b58cebd commit 9fcde1e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions protoscribe/language/morphology/morphology.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 9fcde1e

Please sign in to comment.