how to use spacy lemmatizer to get a word into basic form

后端 未结 5 1311
青春惊慌失措
青春惊慌失措 2021-02-02 08:25

I am new to spacy and I want to use its lemmatizer function, but I don\'t know how to use it, like I into strings of word, which will return the string with the basic form the w

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-02 08:45

    I used:

    import spacy
    
    nlp = en_core_web_sm.load()
    doc = nlp("did displaying words")
    print(" ".join([token.lemma_ for token in doc]))
    >>> do display word
    

    But it gived OSError: [E050] Can't find model 'en_core_web_sm'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory. error, I used:

    pip3 install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz
    

    to get rid of error.

提交回复
热议问题