Skip to content

Instantly share code, notes, and snippets.

@Sirsirious
Created February 26, 2020 21:37
Show Gist options
  • Save Sirsirious/0c3186249e7c39aec5c07a9b688cd8b3 to your computer and use it in GitHub Desktop.
Save Sirsirious/0c3186249e7c39aec5c07a9b688cd8b3 to your computer and use it in GitHub Desktop.
Some examples of postaggers
##In nltk
import nltk
from nltk import word_tokenize
text = word_tokenize("This is a tagged sentence")
print(nltk.pos_tag(text))
#In spaCy
import spacy
nlp = spacy.load('en')
doc = nlp("This is a tagged sentence")
tags = []
for token in doc:
tags.append((token.pos_, token))
print(tags)
#In textblob
from textblob import TextBlob
text = TextBlob("This is a tagged sentence")
print(text.tags)
#Btw, this is the same tagger from nltk...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment