Shriharsh commited on
Commit
3987840
·
verified ·
1 Parent(s): 049f57d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -34,7 +34,7 @@ def preprocess_qa_format(text):
34
  "Answer: [answer]\nQuestion: [question]"
35
  """
36
 
37
- # Matches explicit "Question X: ..." followed by "Answer: ..."
38
  pattern1 = re.compile(r"(?i)question\s*\d*\s*:\s*(.+?)\n\s*answer[:]*\s*(.+?)(?:\n|$)")
39
 
40
  # Matches "Q X: ..." followed by "A: ..."
@@ -46,6 +46,7 @@ def preprocess_qa_format(text):
46
  def replacer(match):
47
  question_text = match.group(1).strip()
48
  answer_text = match.group(2).strip()
 
49
  return f"Answer: {answer_text}\nQuestion: {question_text}\n"
50
 
51
  # Apply transformations
 
34
  "Answer: [answer]\nQuestion: [question]"
35
  """
36
 
37
+ # Matches "Question X: ..." followed by "Answer: ..."
38
  pattern1 = re.compile(r"(?i)question\s*\d*\s*:\s*(.+?)\n\s*answer[:]*\s*(.+?)(?:\n|$)")
39
 
40
  # Matches "Q X: ..." followed by "A: ..."
 
46
  def replacer(match):
47
  question_text = match.group(1).strip()
48
  answer_text = match.group(2).strip()
49
+ # Put the answer first, then the question.
50
  return f"Answer: {answer_text}\nQuestion: {question_text}\n"
51
 
52
  # Apply transformations