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

Identifying named entities in news headlines

News organizations often tag named entities like people, locations, and organizations in headlines to improve search, indexing, and recommendations. Your job is to use a Hugging Face pipeline to automatically detect and group these entities in a news headline.

Bu egzersiz

Natural Language Processing (NLP) in Python

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

Egzersiz talimatları

  • Create a ner_pipeline using the "dslim/bert-base-NER" model.
  • Extract the named entities from the given headline.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

from transformers import pipeline
# Create the NER pipeline
ner_pipeline = pipeline(
    task="____",
    model="____",
    grouped_entities=True
)
headline = "Apple is planning to open a new office in San Francisco next year."

# Get named entities
entities = ____

for entity in entities:
    print(f"{entity['entity_group']}: {entity['word']}")
Kodu Düzenle ve Çalıştır