文法正確性
文字分類是將輸入文字標註到預先定義的類別。常見例子包括情緒分類(positive 或 negative)、垃圾郵件偵測(spam 或 not spam),甚至是文法錯誤偵測。
試著使用 text-classification pipeline 來檢查輸入句子的文法是否有誤。
transformers 函式庫中的 pipeline 已為你載入。
本練習屬於課程
善用 Hugging Face
練習說明
- 建立一個用於
text-classification的 pipeline,並使用模型"abdulmatinomotoso/English_Grammar_Checker",將此 pipeline 儲存為grammar_checker。 - 使用
grammar_checker對提供的輸入句子進行文法正確性預測,並將結果儲存為output。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Create a pipeline for grammar checking
____ = ____(
____="text-classification",
____="abdulmatinomotoso/English_Grammar_Checker"
)
# Check grammar of the input text
output = ____("I will walk dog")
print(output)