Skip to content

Instantly share code, notes, and snippets.

@evgenybf
Created June 5, 2018 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evgenybf/fd0638ef3b280d21e62ea920d1a5b46d to your computer and use it in GitHub Desktop.
Save evgenybf/fd0638ef3b280d21e62ea920d1a5b46d to your computer and use it in GitHub Desktop.
A trivial example of part of speech recognition with spacy module
# 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