Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements a RegexpTagger #2533

Merged
merged 8 commits into from
Dec 1, 2021
Merged

Implements a RegexpTagger #2533

merged 8 commits into from
Dec 1, 2021

Conversation

MaxDall
Copy link
Collaborator

@MaxDall MaxDall commented Nov 30, 2021

No description provided.

@alanakbik
Copy link
Collaborator

@MaxDall works well! Thanks for adding this!

You can call the tagger and define regular expressions that match to span annotations. I.e.:

    # sentence with a number and two quotes
    sentence = Sentence('Figure 11 is both "too colorful" and "not informative enough".')

    # instantiate regex tagger with a quote matching pattern
    tagger = RegexpTagger(mapping=(r'(["\'])(?:(?=(\\?))\2.)*?\1', 'QUOTE'))

    # also add a number mapping
    tagger.register_labels(mapping=(r'\b\d+\b', 'NUMBER'))

    # tag sentence
    tagger.predict(sentence)

    # check out matches
    for entity in sentence.get_labels():
        print(entity)

@alanakbik alanakbik merged commit b766b5b into flairNLP:master Dec 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants