Views
No views yet
1from flair.data import Sentence
2from flair.models import SequenceTagger
3
4# load tagger
5tagger = SequenceTagger.load("aehrm/droc-character-recognizer")
6
7# make example sentence
8sentence = Sentence("Effi folgte Graf Instetten nach Kessin.")
9
10# predict NER tags
11tagger.predict(sentence)
12
13# print sentence
14print(sentence)
15# >>> Sentence[7]: "Effi folgte Graf Instetten nach Kessin." → ["Effi"/PER, "Graf Instetten"/PER]
16
17# print predicted NER spans
18print('The following NER tags are found:')
19# iterate over entities and print
20for entity in sentence.get_spans('character'):
21 print(entity)
22# >>> Span[0:1]: "Effi" → PER (1.0)
23# >>> Span[2:4]: "Graf Instetten" → PER (1.0)
@inproceedings{ehrmanntraut-et-al-llpro-2023,
address = {Ingolstadt, Germany},
title = {{LLpro}: A Literary Language Processing Pipeline for {German} Narrative Text},
booktitle = {Proceedings of the 10th Conference on Natural Language Processing ({KONVENS} 2022)},
publisher = {{KONVENS} 2023 Organizers},
author = {Ehrmanntraut, Anton and Konle, Leonard and Jannidis, Fotis},
year = {2023},
}