From 40c7977f9b8c6904ff7cae09b73c9d8366fe3ff1 Mon Sep 17 00:00:00 2001 From: Badis Ghoubali <110173477+BadisG@users.noreply.github.com> Date: Mon, 29 Jan 2024 01:41:28 +0100 Subject: [PATCH] Add roleplay.gbnf grammar (#5368) --- grammars/roleplay.gbnf | 4 ++++ modules/ui_parameters.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 grammars/roleplay.gbnf diff --git a/grammars/roleplay.gbnf b/grammars/roleplay.gbnf new file mode 100644 index 00000000..47222641 --- /dev/null +++ b/grammars/roleplay.gbnf @@ -0,0 +1,4 @@ +phrasePattern ::= "*" [A-ZÀ-Ü] ( [A-Za-z'.?!,:;-à-üÀ-Ü0-9]+ " " )* [A-Za-z'.?!,:;-à-üÀ-Ü0-9]+ "*" +quotedText ::= "\"" [A-ZÀ-Ü] [A-Za-z'.*?!,:;-à-üÀ-Ü0-9]* (" " [A-Za-z'.*?!,:;-à-üÀ-Ü0-9]+)* "\"" +root ::= phrasePattern singleSpace quotedText singleSpace phrasePattern singleSpace quotedText singleSpace (phrasePattern singleSpace quotedText singleSpace)? +singleSpace ::= " " diff --git a/modules/ui_parameters.py b/modules/ui_parameters.py index fafdcacc..63a3743a 100644 --- a/modules/ui_parameters.py +++ b/modules/ui_parameters.py @@ -115,6 +115,6 @@ def get_truncation_length(): def load_grammar(name): p = Path(f'grammars/{name}') if p.exists(): - return open(p, 'r').read() + return open(p, 'r', encoding='utf-8').read() else: return ''