Skip to content

Instantly share code, notes, and snippets.

@glennhefley
Created February 21, 2022 07:38
Show Gist options
  • Save glennhefley/95671965f76b30c604a5bf9a3ade1981 to your computer and use it in GitHub Desktop.
Save glennhefley/95671965f76b30c604a5bf9a3ade1981 to your computer and use it in GitHub Desktop.
NLTK passage into with TextBlob.py
#!python
'''
In a nut shell textBlob fits all my needs. This little gem took less than thirty minutues from discovery to completion. Prototyping will now be a simple matter, and proofs of concepts down to the improv level of setup requirments.
'''
import re
from textblob import TextBlob
px = 'VB?' # search for later
text = '''
“Doesn’t look like that’s going to work out for you,” Oma said, as she examined my situation. She blew a lock of gray hair from her face, “Nope, you look wide awake. Want’a try it again? I could re-play the clip. It might take.”
“No, thank you,” I said, spacing out my words so they would be clear, and lacking any confusion. “So, you believe those two are my parents?”
“No,” she said. “I know they are. I’m from that tribe originally. What? You believe I just tell people I don’t know painful things to observe them for science reasons?”
Maybe, I thought but before I could say anything she said, “I was there when your grandfather took you. My memory didn’t trigger until the boys showed me those pictures of your grandfather. I asked them to find other photos from when he was younger. They had them the next day. Then I was sure of who he was. When I saw you, it wasn’t a question if you were Sades’ daughter. You look just like her. No, I’m telling you and wondering what you might want to do about it?”
'''
myblob = TextBlob(text) # and that's it for setup. That could be a chapter or a novel I've discovered.
# now show me verbs
for sentence in myblob.sentences:
for word, pos in sentence.tags:
if re.match(px, pos):
print(word)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment