官方 DOC 练习

安装

pip install spacy
python -m spacy.en.download

In [1]:
import spacy.en
from spacy.parts_of_speech import ADV

In [ ]:
nlp = spacy.en.English()
tokens = nlp(
    "‘Give it back,’ he pleaded abjectly, ‘it’s mine.’",
    tag=True, parse=False)
posed_tokens = [tok.string.upper() if tok.pos == ADV else tok.string for tok in tokens]
print(''.join(posed_tokens))

In [ ]:
nlp.vocab['test'].prob