Skip to content

Commit 3bd28dc

Browse files
committed
use simpler xor pattern without negative lookahead for OneOf
1 parent 4985d16 commit 3bd28dc

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

Diff for: outlines/fsm/json_schema.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,7 @@ def to_regex(
195195
to_regex(resolver, t, whitespace_pattern) for t in instance["oneOf"]
196196
]
197197

198-
xor_patterns = []
199-
# json schema validation ensured there is no overlapping schemas in oneOf
200-
for subregex in subregexes:
201-
other_subregexes = filter(lambda r: r != subregex, subregexes)
202-
other_subregexes_str = "|".join([f"{s}" for s in other_subregexes])
203-
negative_lookahead = f"(?!.*({other_subregexes_str}))"
204-
xor_patterns.append(f"({subregex}){negative_lookahead}")
198+
xor_patterns = [f"(?:{subregex})" for subregex in subregexes]
205199

206200
return rf"({'|'.join(xor_patterns)})"
207201

0 commit comments

Comments
 (0)