summaryrefslogtreecommitdiff
path: root/examples/json_schema_to_grammar.py
diff options
context:
space:
mode:
authorOlivier Chafik <ochafik@users.noreply.github.com>2024-06-11 02:22:57 +0100
committerGitHub <noreply@github.com>2024-06-11 02:22:57 +0100
commitb61eb9644d64e90123ac805436d95b94b3b4cc3f (patch)
tree901482757f27f7430e945e41d4437927de946be6 /examples/json_schema_to_grammar.py
parent396b18dfec2c56846e80362db70af09b9e1d70ba (diff)
json: refine constraint for whitespace to avoid runaways yet allow pretty print (#7866)
Diffstat (limited to 'examples/json_schema_to_grammar.py')
-rwxr-xr-xexamples/json_schema_to_grammar.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/examples/json_schema_to_grammar.py b/examples/json_schema_to_grammar.py
index cd444d01..ab19e20d 100755
--- a/examples/json_schema_to_grammar.py
+++ b/examples/json_schema_to_grammar.py
@@ -29,9 +29,8 @@ class BuiltinRule:
self.content = content
self.deps = deps or []
-# whitespace is constrained to a single space char to prevent model "running away" in
-# whitespace. Also maybe improves generation quality?
-SPACE_RULE = '" "?'
+# Constraining spaces to prevent model "running away".
+SPACE_RULE = '| " " | "\\n" [ \\t]{0,20}'
PRIMITIVE_RULES = {
'boolean' : BuiltinRule('("true" | "false") space', []),