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

Cannot extract all entities which had same range values #17

Open
dgks0n opened this issue Jun 30, 2020 · 0 comments
Open

Cannot extract all entities which had same range values #17

dgks0n opened this issue Jun 30, 2020 · 0 comments

Comments

@dgks0n
Copy link

dgks0n commented Jun 30, 2020

I made an example as below by using spacy with lookup dependencies.

entity = Entity(
    keywords_list=["Japan", "Tokyo", "US"],
    label='from_location',
    case_sensitive=True)
nlp.add_pipe(entity, name='location')

entity2 = Entity(
    keywords_list=["Korea", "Japan", "US", "Tokyo"],
    label='to_location',
    case_sensitive=True)
nlp.add_pipe(entity2, name='to_location')

doc = nlp(
    u"I want to go to Tokyo Japan tomorrow morning from US. Can you book a ticket?")
for token in doc:
    if token._.is_entity:
        pprint([(token.text, token._.canonical, token.ent_type_, token.pos_, token.idx, token.idx + len(token.text))])

Here is the result:

[('Tokyo', 'Tokyo', 'from_location', 'X', 16, 21)]
[('Japan', 'Japan', 'from_location', 'X', 22, 27)]
[('US', 'US', 'from_location', 'X', 50, 52)]

However, my expectation is:

[('Tokyo', 'Tokyo', 'to_location', 'X', 16, 21)]
[('Tokyo', 'Tokyo', 'from_location', 'X', 16, 21)]
[('Japan', 'Japan', 'to_location', 'X', 22, 27)]
[('Japan', 'Japan', 'from_location', 'X', 22, 27)]
[('US', 'US', 'to_location', 'X', 50, 52)]
[('US', 'US', 'from_location', 'X', 50, 52)]

Is there anyone know why?

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

1 participant