Created
October 14, 2016 17:11
-
-
Save ctava/628b120c5a738a9b87a7b0b7e9f12c99 to your computer and use it in GitHub Desktop.
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
import spacy.en | |
from spacy.parts_of_speech import ADV | |
from spacy.parts_of_speech import NOUN | |
nouns = [''] | |
adverbs = [''] | |
# Load the pipeline, and call it with some text. | |
nlp = spacy.en.English() | |
doc = "The quick brown fox jumps over the lazy dog" | |
tokens = nlp(doc, tag=True, parse=False) | |
for tok in tokens: | |
if tok.pos == NOUN: | |
nouns.append(tok.string) | |
if tok.pos == ADV: | |
adverbs.append(tok.string) | |
print("nouns: " + ', '.join(nouns)) | |
print("\n") | |
print("adverbs: " + ','.join(adverbs)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment