Created
February 26, 2020 21:37
-
-
Save Sirsirious/0c3186249e7c39aec5c07a9b688cd8b3 to your computer and use it in GitHub Desktop.
Some examples of postaggers
This file contains 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
##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