From 333cce2f9a9a8eb543d8be144774a0449c1ec2e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kay-Michael=20W=C3=BCrzner?= Date: Fri, 17 Dec 2021 17:21:34 +0100 Subject: [PATCH] Fix usage of symbol table for lookup --- timur/fsts/timur_fst.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/timur/fsts/timur_fst.py b/timur/fsts/timur_fst.py index fdc5d41..d45fc93 100644 --- a/timur/fsts/timur_fst.py +++ b/timur/fsts/timur_fst.py @@ -38,13 +38,14 @@ def lookup(self, string): ''' Analyse a string ''' - result = [] - if self.__verify(): - string_accep = pynini.accep(" ".join(c for c in string), token_type=self.__syms.alphabet) - intermediate = pynini.compose(self.__timur, string_accep) - paths = intermediate.paths(input_token_type=intermediate.input_symbols(),output_token_type=intermediate.output_symbols()) - result = list(paths.items()) - return result + with pynini.default_token_type(self.__syms.alphabet): + result = [] + if self.__verify(): + string_accep = pynini.accep(" ".join(c for c in string)) + intermediate = pynini.compose(self.__timur, string_accep) + paths = intermediate.paths() + result = list(paths.items()) + return result def load(self, fst): '''