Skip to content

Commit

Permalink
Allow Parenthesis in STRING_INNER (#899)
Browse files Browse the repository at this point in the history
Fix #838


06d5654
erroneously disallowed parenthesis in strings. This PR allows
parenthesis in strings.
  • Loading branch information
lapp0 authored May 18, 2024
1 parent 3e291b1 commit 7863f8e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion outlines/fsm/json_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from referencing._core import Resolver
from referencing.jsonschema import DRAFT202012

STRING_INNER = r'([^("\\\x00-\x1f\x7f-\x9f)]|\\\\)'
STRING_INNER = r'([^"\\\x00-\x1f\x7f-\x9f]|\\\\)'
STRING = f'"{STRING_INNER}*"'
INTEGER = r"(-)?(0|[1-9][0-9]*)"
NUMBER = rf"({INTEGER})(\.[0-9]+)?([eE][+-][0-9]+)?"
Expand Down
2 changes: 2 additions & 0 deletions tests/fsm/test_json_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ def test_match_number(pattern, does_match):
STRING,
[
("unquotedstring", False),
('"(parenthesized_string)"', True),
('"malformed) parenthesis (((() string"', True),
('"quoted_string"', True),
(r'"escape_\character"', False),
(r'"double_\\escape"', True),
Expand Down

0 comments on commit 7863f8e

Please sign in to comment.