Created
June 5, 2018 18:58
-
-
Save evgenybf/fd0638ef3b280d21e62ea920d1a5b46d to your computer and use it in GitHub Desktop.
A trivial example of part of speech recognition with spacy module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install spacy | |
# python -m spacy download en_core_web_sm | |
import spacy | |
# Load English tokenizer, tagger, parser, NER and word vectors | |
nlp = spacy.load('en_core_web_sm') | |
# Process whole documents | |
text = ("I saw hem. He is a saw.") | |
doc = nlp(text) | |
for token in doc: | |
print(token.text, token.lemma_, token.pos_) | |
print('-' * 10) | |
print("|".join(token.text_with_ws for token in doc)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment