Skip to content

Instantly share code, notes, and snippets.

@kasperjunge
Last active August 16, 2022 06:45
Show Gist options
  • Save kasperjunge/04d65442d948d0c6b9bc028b9b87b699 to your computer and use it in GitHub Desktop.
Save kasperjunge/04d65442d948d0c6b9bc028b9b87b699 to your computer and use it in GitHub Desktop.
Danish SOTA NER
import pandas as pd
from transformers import pipeline
text = """
Dan Saattrup Nielsen arbejder som AI Specialist hos Alexandra Instituttet
og er han næstformand i Dansk Data Science Community.
"""
ner = pipeline(
task="ner",
model="saattrupdan/nbailab-base-ner-scandi",
aggregation_strategy="first"
)
result = ner(text)
print(pd.DataFrame.from_records(result))
# Output:
# entity_group score word start end
# 0 PER 0.999734 Dan Saattrup Nielsen 1 21
# 1 ORG 0.998360 Alexandra Instituttet 53 74
# 2 ORG 0.999438 Dansk Data Science Community 104 132
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment