Aan de slagGa gratis aan de slag

Checking grammatical correctness

An educational app is being built to help users improve their grammar. One core feature automatically checks whether user-submitted sentences are grammatically acceptable. You've been asked to implement this feature using a model trained on the Corpus of Linguistic Acceptability (CoLA) to classify sentence correctness.

Deze oefening maakt deel uit van de cursus

Natural Language Processing (NLP) in Python

Cursus bekijken

Oefeninstructies

  • Initialize a classifier pipeline with the "textattack/bert-base-uncased-CoLA" model.
  • Use the pipeline to check if the user_text is grammatically acceptable.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

from transformers import pipeline

# Initialize the pipeline
classifier = ____

user_text = "Although she was knowing the answer, she didn't raised her hand during the class discussion."

# Classify grammatical acceptability
result = ____

print(result)
Code bewerken en uitvoeren