例如,我確實有如下代碼,其中
res = get_prediction_eos(input_text)
print("res is : ", res)
answer = []
print("res ", res['bert'].split("\n"))
for i in res['bert'].split("\n"):
answer.append(i)
answer_as_string = " ".join(answer)
print("answer is : ", answer_as_string)
上述代碼的輸出回傳如下:
res is : {'bert': 'up\nwrong\nhappening\nnew\nhappened'}
res ['up', 'wrong', 'happening', 'new', 'happened']
answer is : up wrong happening new happened
我確實有如下代碼的文本:
text = "Hey what's"
主要需要的輸出是“答案是:錯誤發生了新的事情”。我確實有一個像'嘿什么'這樣的文本,我想將答案的輸出添加到文本中,比如
Hey what's up
Hey what's wrong
Hey what's happening
Hey what's new
Hey what's happened
誰能幫我寫代碼?
uj5u.com熱心網友回復:
您只需要遍歷串列并列印文本 回圈中的元素。
在 Python >= 3.6 中:
for e in res['bert'].split('\n'):
print(f'{text} {e}?')
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/410513.html
標籤:
