Pranjal12345 commited on
Commit
80e218f
1 Parent(s): 61625a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -40,9 +40,13 @@ def generate_question_answer_pairs(input_file):
40
  if type(i) == dict:
41
  continue
42
  pair = i[0]['generated_text']
43
- question_part = re.search(r'^(.*?\?)',pair).group(1).strip()
44
- answer_part = re.search(r'\?(.*)', pair).group(1).strip()
45
- result += f"Question: {question_part}\nAnswer: {answer_part}\n\n"
 
 
 
 
46
 
47
  return result
48
 
 
40
  if type(i) == dict:
41
  continue
42
  pair = i[0]['generated_text']
43
+ question = re.search(r'^(.*?\?)', pair)
44
+ answer = re.search(r'\?(.*)', pair)
45
+
46
+ if question and answer:
47
+ question_part = question.group(1).strip()
48
+ answer_part = answer.group(1).strip()
49
+ result += f"Question: {question_part}\nAnswer: {answer_part}\n\n"
50
 
51
  return result
52