Jayce-Ping commited on
Commit
7eed899
·
verified ·
1 Parent(s): d0d1129

Upload Consistency_Annotation/utils.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. Consistency_Annotation/utils.py +13 -0
Consistency_Annotation/utils.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+
3
+
4
+ def divide_prompt(prompt):
5
+ # seqis like ". [TOP-LEFT]:"
6
+ match_sep = re.compile(r"\.\s+[A-Z0-9-\[\]]+:")
7
+ seps = match_sep.findall(prompt)
8
+ # Add '.' for each sentence
9
+ sub_prompts = [
10
+ p + '.' if p.strip()[-1] != '.' else p
11
+ for p in re.split('|'.join(map(re.escape, seps)), prompt)
12
+ ]
13
+ return sub_prompts