MCPcopy Create free account
hub / github.com/OrangeInSouth/DeePEn / answer_extract

Function answer_extract

utils/answer_extract.py:1–15  ·  view source on GitHub ↗
(text, demon_count, split_key_before_list, split_key_behind_list)

Source from the content-addressed store, hash-verified

1def answer_extract(text, demon_count, split_key_before_list, split_key_behind_list):
2 model_answer = text.split(split_key_before_list[0])[demon_count + 1:]
3 try:
4 prediction = model_answer[0]
5 if len(split_key_before_list) > 1:
6 try:
7 prediction = prediction.split(split_key_before_list[1])[-1]
8 except:
9 pass
10 for split_key_behind in split_key_behind_list:
11 if split_key_behind in prediction:
12 prediction = prediction.split(split_key_behind)[0]
13 except:
14 prediction = ""
15 return model_answer, prediction

Callers 1

runMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected