From 6181bdaeb3a26ee38e8d60156c3d12456f12fab4 Mon Sep 17 00:00:00 2001 From: Isin Demirsahin Date: Fri, 20 Oct 2023 11:24:37 -0700 Subject: [PATCH] No public description PiperOrigin-RevId: 575272871 --- nisaba/scripts/natural_translit/utils/type_op.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nisaba/scripts/natural_translit/utils/type_op.py b/nisaba/scripts/natural_translit/utils/type_op.py index 0d690844..fb834b08 100644 --- a/nisaba/scripts/natural_translit/utils/type_op.py +++ b/nisaba/scripts/natural_translit/utils/type_op.py @@ -58,7 +58,7 @@ def value_from_list(some_list, index, exclude=UNSPECIFIED, instead=0): import logging import numbers -from typing import Dict, Iterable, List, NamedTuple, Tuple, Union +from typing import Dict, Iterable, List, NamedTuple, Tuple, Union, Callable import pynini as pyn # Custom types @@ -631,3 +631,11 @@ def in_attribute( look_for, get_attribute(thing, attr), keys, enf_list, enf_dict, enf_range, allow_none ) + + +# TODO: Switch to list_op and remove duplicate when is fixed. +def apply_foreach( + func: Callable[[Valid,], Valid], arg_list: List[Valid] +) -> list[...]: + """Temporary duplicate of apply_foreach in list_op with Valid type.""" + return [func(*args) for args in arg_list]