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

Tokens not properly split when using emoji with modifiers #10

Open
timonmohaupt opened this issue Oct 27, 2020 · 1 comment
Open

Tokens not properly split when using emoji with modifiers #10

timonmohaupt opened this issue Oct 27, 2020 · 1 comment

Comments

@timonmohaupt
Copy link

import spacy
from spacymoji import Emoji

def test():
    nlp = spacy.load('en_core_web_sm')
    emoji = Emoji(nlp, merge_spans=True)
    nlp.add_pipe(emoji, first=True)
    doc = nlp(
        'Word!👍🏿')
    for token in doc:
        print (token)
    doc = nlp(
        'Word! 👍🏿')
    for token in doc:
        print(token)
    doc = nlp(
        'Word!👍')
    for token in doc:
        print(token)
    return doc

Shows the problem. "Word!" is not correctly split into "Word" and "!", when the thumbs up has a dark skin tone modifier.

@abushoeb
Copy link

abushoeb commented Nov 23, 2020

Try this

import spacy
from spacymoji import Emoji

nlp = spacy.load("en_core_web_sm")
emoji = Emoji(nlp, merge_spans=True)
nlp.add_pipe(emoji, first=True)

# case 1
doc = nlp('Word!👍🏿')
print([token.text for token in doc])

# case 2
doc = nlp('Word! 👍🏿')
print([token.text for token in doc])

Expected Output

['Word!', '👍🏿']
['Word', '!', '👍🏿']

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

No branches or pull requests

2 participants