From 356c9be42e1ed94411948a389444b72c740183ef Mon Sep 17 00:00:00 2001 From: Benedikt Fuchs Date: Sat, 11 Nov 2023 02:15:53 +0100 Subject: [PATCH] fix vocabulary for SequenceParser --- lmformatenforcer/characterlevelparser.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lmformatenforcer/characterlevelparser.py b/lmformatenforcer/characterlevelparser.py index 8e86db7..02cd11a 100644 --- a/lmformatenforcer/characterlevelparser.py +++ b/lmformatenforcer/characterlevelparser.py @@ -130,12 +130,12 @@ def add_character(self, new_character: str) -> CharacterLevelParser: return UnionParser(legal_parsers) def get_allowed_characters(self) -> str: - allowed_character_strs = [] + allowed_characters = set() for parser in self.parsers: - allowed_character_strs.append(parser.get_allowed_characters()) + allowed_characters.update(parser.get_allowed_characters()) if not parser.can_end(): break - return "".join([parser.get_allowed_characters() for parser in self.parsers]) + return "".join(allowed_characters) def can_end(self) -> bool: return all([parser.can_end() for parser in self.parsers])