Add roleplay.gbnf grammar (#5368)

This commit is contained in:
Badis Ghoubali 2024-01-29 01:41:28 +01:00 committed by GitHub
parent b1463df0a1
commit 40c7977f9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

4
grammars/roleplay.gbnf Normal file
View File

@ -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 ::= " "

View File

@ -115,6 +115,6 @@ def get_truncation_length():
def load_grammar(name): def load_grammar(name):
p = Path(f'grammars/{name}') p = Path(f'grammars/{name}')
if p.exists(): if p.exists():
return open(p, 'r').read() return open(p, 'r', encoding='utf-8').read()
else: else:
return '' return ''