Jayce-Ping's picture
Add files using upload-large-folder tool
436c9ff verified
raw
history blame
354 Bytes
import re
def divide_prompt(prompt):
# seqis like ". [TOP-LEFT]:"
match_sep = re.compile(r"\.\s+[A-Z0-9-\[\]]+:")
seps = match_sep.findall(prompt)
# Add '.' for each sentence
sub_prompts = [
p + '.' if p.strip()[-1] != '.' else p
for p in re.split('|'.join(map(re.escape, seps)), prompt)
]
return sub_prompts