Skip to content

Commit

Permalink
[WIP] Remove gen parsing logic
Browse files Browse the repository at this point in the history
  • Loading branch information
JayYip committed Jun 4, 2019
1 parent b73d9c4 commit e3ce351
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions docproduct/predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,14 @@ def predict(self, questions, search_by='answer', topk=5, answer_only=False):
lambda: gpt2_estimator.predict_input_fn(inputs=gpt2_input, batch_size=self.batch_size, checkpoint_path=self.gpt2_weight_file))
raw_output = gpt2_estimator.predictions_parsing(
gpt2_pred, self.encoder)
result_list = [re.search('`ANSWER:(.*)`QUESTION:', s)
for s in raw_output]
result_list = [s for s in result_list if s]
try:
r = result_list[0].group(1)
except (AttributeError, IndexError):
r = topk_answer[0]
return r
# result_list = [re.search('`ANSWER:(.*)`QUESTION:', s)
# for s in raw_output]
# result_list = [s for s in result_list if s]
# try:
# r = result_list[0].group(1)
# except (AttributeError, IndexError):
# r = topk_answer[0]
return raw_output


if __name__ == "__main__":
Expand Down

0 comments on commit e3ce351

Please sign in to comment.