將顧客評論翻譯成法文
一家全球電商公司正在分析英語使用者的顧客回饋。為了支援法國的客服團隊,公司需要把這些評論翻譯成法文。做為 NLP 管線的一環,你的任務是使用 Hugging Face 的管線自動化翻譯這些評論。
本練習屬於課程
Python 的 Natural Language Processing(NLP)
練習說明
- 使用
"Helsinki-NLP/opus-mt-en-fr"模型建立一個translator管線。 - 將提供的
review從英文翻譯成法文。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
from transformers import pipeline
# Create the translation pipeline
translator = pipeline(task="____", model="____")
review = "The hotel was clean and the staff were very friendly."
# Translate the review
translation = ____
print(translation)