[Python] Is there a way to match on any token of a given text in SpaCy?

Discussão em 'Python' iniciado por Stack, Março 5, 2025.

  1. Stack

    Stack Membro Participativo

    I currently have the following:

    import spacy

    nlp = spacy.load("en_core_web_sm")

    doc = nlp("Apple is looking at buying U.K. startup for $1 billion")
    query = nlp("U.K. startup")

    for token in doc:
    if token.text in [token.text for token in query]:
    ...


    Is there a better way to do this?

    Continue reading...

Compartilhe esta Página