開始使用免費開始

文法正確性

文字分類是將輸入文字標註到預先定義的類別。常見例子包括情緒分類(positivenegative)、垃圾郵件偵測(spamnot 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)
編輯並執行程式碼