Created
June 17, 2019 12:29
-
-
Save DhruvParanjape/56e6dadd7de2a6f5d714b1af0f2038ed to your computer and use it in GitHub Desktop.
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
from nltk import word_tokenize, pos_tag | |
sentence = """ | |
thank you for crying in the customer service my name is b glad to assist you how can help you to find yes my name is and i'm i have a beer tell and i i'm i hadn't seen the ladder on that said that on i get my direct deposit so that it sounds so i try to call social security to have me i'm all yes ma'am i'm here all okay i i've tried to call social security traps and yeah i'm insurrection pocket moves to a different house and a wall on the routing number and your cat on and that's how the number of the account which | |
""" | |
tokens = word_tokenize(sentence) | |
tokens=[token.lower() for token in tokens if token.isalpha()] | |
print("tokens : ", tokens) | |
tags = pos_tag(tokens) | |
nouns = [] | |
verbs = [] | |
for word, tag in tags: | |
if tag == "NN": | |
nouns.append(word) | |
elif tag == "VBP": | |
verbs.append(word) | |
print("nouns : ", nouns) | |
print("verbs : ", verbs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment