I am trying to use flair to create an annotation of a document using IOB tags.
I am using the pretrained ner-ontonotes model.
I used the to_tagged_string() function where it produces the following output:
A 35
My question is, is there a library function to grab those words and their tags?
My goal is to produce this kind of annotation text file
A O
35 B-PERCENT
percent I-PERCENT
....
I am newbie, so forgive me if I came across as vague.
@TheArowanaDude there are several ways to do this. You could for instance iterate over all tokens in a sentence and print out the fields that you need:
for token in sentence:
print(f'{token.text} {token.get_tag('ner')}')
You could also iterate over full NER tags if that is helpful:
for ner in sentence.get_spans('ner):
print(ner)
Most helpful comment
@TheArowanaDude there are several ways to do this. You could for instance iterate over all tokens in a sentence and print out the fields that you need:
You could also iterate over full NER tags if that is helpful: