41th Introduction to Translation News Summary Project
ChatGPT:
本文介紹了翻譯專案,包括使用開放式 AI 進行翻譯,以及雲供應商的翻譯服務。作者還提到了一個簡單的專案,可以搜索一個國家的報紙,並使用 Openai 將其翻譯成英語,以提供該國的新聞摘要。但是,Openai 擅長翻譯其他語言到英語,而從非英語語言到另一種非英語語言的翻譯不是很好。建議將 Openai 用於英語翻譯,而雲供應商的翻譯服務則更適合其他語言。
42th Scraping International Newspaper Sites
Note:
實際執行的一些小細節
Request 取得 response
BeautifulSoup 解析 html select by class name
將 url, tag 整進 dictionary 中,減少重複 code
43th OpenAI Translation and Summary
Note:
prompt = “Detect the language of the news headlines below, then translate a summary of the headlines to English in a conversational tone:\n”
parameter
def translate_and_summary(prompt):
response = openai.Completion.create(
model="text-davinci-003",
prompt=prompt,
temperature=0.1, # Helps conversational tone a bit, optional
max_tokens=200,
top_p=1.0,
frequency_penalty=0.0,
presence_penalty=0.0
)
print(response['choices'][0]['text'])