Views
No views yet
1from transformers import pipeline
2
3model_id = "haukelicht/roberta-base-group-mention-detector-uk-manifestos"
4
5classifier = pipeline(task="ner", model=model_id, aggregation_strategy="simple")
6
7text = "Our party fights for the deprived and the vulnerable in our country."
8annotations = classifier(text)
9print(annotations)
10
11# get annotations' character start and end indexes
12locations = [(anno['start'], anno['end']) for anno in annotations]
13locations
14
15# index the source text using first annotation as an example
16loc = locations[0]
17text[slice(*loc)]| type | seq-eval F1 | soft seq-eval F1 | sentence level F1 |
|---|---|---|---|
| social group | 0.638 | 0.739 | 0.928 |
| political group | 0.905 | 0.920 | 0.990 |
| political institution | 0.645 | 0.698 | 0.954 |
| organization, public institution, or collective actor | 0.546 | 0.552 | 0.928 |
| implicit social group reference | 0.613 | 0.537 | 0.943 |