BaşlayınÜcretsiz Başlayın

Part of Speech tagging for text analysis

A language learning app wants to help users understand sentence structure by highlighting the grammatical role of each word. Your task is to use a Hugging Face pipeline to label each word in a given sentence with its corresponding PoS tag.

Bu egzersiz

Natural Language Processing (NLP) in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Create a pos_pipeline using the "vblagoje/bert-english-uncased-finetuned-pos" model.
  • Apply the pipeline on the provided sentence.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

from transformers import pipeline
# Create the PoS tagging pipeline
pos_pipeline = pipeline(
    task="____",
    model="____",
    grouped_entities=True
)

sentence = "I am meeting my friends for coffee this afternoon."

# Get PoS tags
pos_tags = ____
for token in pos_tags:
    print(f"{token['word']}: {token['entity_group']}")
Kodu Düzenle ve Çalıştır