vinayakdev commited on
Commit
effac9d
1 Parent(s): a8e1f24

Update generator.py

Browse files
Files changed (1) hide show
  1. generator.py +4 -0
generator.py CHANGED
@@ -89,6 +89,8 @@ def QA(question, context):
89
  predict_answer_tokens = inputs.input_ids[0, start : end + 1]
90
  output = tokenizer.decode(predict_answer_tokens, skip_special_tokens=True)
91
  output = string.capwords(output)
 
 
92
  return f"Q. {question} \n Ans. {output}"
93
  # QA("What was the first C program","The first prgram written in C was Hello World")
94
 
@@ -129,6 +131,8 @@ def creator(context):
129
  pairs = []
130
  for ques in questions:
131
  pair = QA(ques,context)
 
 
132
  print(pair)
133
  pairs.append(pair)
134
  return pairs
 
89
  predict_answer_tokens = inputs.input_ids[0, start : end + 1]
90
  output = tokenizer.decode(predict_answer_tokens, skip_special_tokens=True)
91
  output = string.capwords(output)
92
+ if string.isspace(output) or len(output) == 0:
93
+ return ""
94
  return f"Q. {question} \n Ans. {output}"
95
  # QA("What was the first C program","The first prgram written in C was Hello World")
96
 
 
131
  pairs = []
132
  for ques in questions:
133
  pair = QA(ques,context)
134
+ if len(pair) == 0:
135
+ continue
136
  print(pair)
137
  pairs.append(pair)
138
  return pairs