Skip to content

Helper function to extract and categorize tags from a loaded Flair SequenceTagger model. The tags are grouped into categories such as person, organization, location, and miscellaneous.

Usage

get_tagger_tags(tagger)

Arguments

tagger

A loaded Flair SequenceTagger model

Value

A list of tags grouped by category:

all

Complete list of all available tags

special

Special tags like , O, ,

person

Person-related tags (e.g., B-PER, I-PER)

organization

Organization tags (e.g., B-ORG, E-ORG)

location

Location tags (e.g., B-LOC, S-LOC)

misc

Miscellaneous entity tags

Details

The tags follow the BIOES (Begin, Inside, Outside, End, Single) scheme:

  • B-: Beginning of multi-token entity (e.g., B-PER in "John Smith")

  • I-: Inside of multi-token entity (e.g., I-PER in "John Smith")

  • O: Outside of any entity

  • E-: End of multi-token entity

  • S-: Single token entity (e.g., S-LOC in "Paris")

See also

load_tagger_ner for loading the NER model

Examples

if (FALSE) { # \dontrun{
# Load a NER model
tagger <- load_tagger_ner("flair/ner-english-large")

# Extract all tags
tags <- get_tagger_tags(tagger)

# Access specific tag categories
print(tags$person)      # All person-related tags
print(tags$location)    # All location-related tags

# Example usage with text annotation
# B-PER I-PER    O    S-ORG
# "John Smith works at Google"

# B-LOC  E-LOC   O   B-ORG    E-ORG
# "New   York    is  United   Nations headquarters"

# Use tags to filter entities
person_entities <- results[tag %in% tags$person]
org_entities <- results[tag %in% tags$organization]
} # }