语法正确性
文本分类是将输入文本标注为预定义类别的过程。它可以用于情感分析(positive 或 negative)、垃圾短信检测(spam 或 not spam),甚至语法错误检测。
请探索如何使用 text-classification 流水线来检查一句输入语句是否存在语法错误。
transformers 库中的 pipeline 已为您加载。
本练习是课程的一部分
使用 Hugging Face
练习说明
- 为任务
text-classification创建一个流水线,并使用模型"abdulmatinomotoso/English_Grammar_Checker",将该流水线保存为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)