ford442 commited on
Commit
a8057ad
·
verified ·
1 Parent(s): a111fd9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -84,12 +84,19 @@ model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map='balanced')
84
  def filter_text(text):
85
  """Filters out the text up to and including 'Rewritten Prompt:'."""
86
  phrase = "Rewritten Prompt: "
 
87
  pattern = f"(.*?){re.escape(phrase)}(.*)"
88
- match = re.search(pattern, text)
 
89
  # match = re.search(pattern, text,flags=re.DOTALL)
90
- if match:
91
- filtered_text = match.group(2)
92
- return filtered_text
 
 
 
 
 
93
  else:
94
  # Handle the case where no match is found
95
  return text
 
84
  def filter_text(text):
85
  """Filters out the text up to and including 'Rewritten Prompt:'."""
86
  phrase = "Rewritten Prompt: "
87
+ phraseB = "rewritten text: "
88
  pattern = f"(.*?){re.escape(phrase)}(.*)"
89
+ patternB = f"(.*?){re.escape(phraseB)}(.*)"
90
+ matchB = re.search(patternB, text)
91
  # match = re.search(pattern, text,flags=re.DOTALL)
92
+ if matchB:
93
+ filtered_text = matchB.group(2)
94
+ match = re.search(pattern, filtered_text)
95
+ if match:
96
+ filtered_text = match.group(2)
97
+ return filtered_text
98
+ else:
99
+ return filtered_text
100
  else:
101
  # Handle the case where no match is found
102
  return text