On using Google’s Perspective API to police the tone of my tweets
A couple weeks ago, Google gave me access to their Perspective API, which can programmatically detect tone from a string of words.
I’m the first to admit that tone can be a problem for me (I get excited easily) so I was gung-ho to see how I could use the tool.
It’s surprised me a few times, and caused me to delete a couple tweets. One was this morning about the opioid epidemic. Sometimes I need the reminder that not everyone feels things as passionately as I do.
One implementation detail I’d handle differently next time is using an API other than the timeline endpoint. This would let me use an account other than @davisshaver to search my tweets and send out the nag. As it stands, it looks like I’m replying to myself. Not to mention, the threading doesn’t seem quite right.
Here are some example tweets that got flagged. This marks the end of my little experiment, at least publicly. I
‘m going to switch to direct messages in the next few days. The hack has proven useful enough that I want to keep it, but not so useful that I want you all to see it.
Here’s what my log output looks like.
Update June 30: I changed my mind on switching to direct messages, mainly because the notifications were funky (read as: nonexistent) when I DM’ed myself. I also tweaked the implementation to address the bugs mentioned above (now struck through). Introducing my bot!
Here’s the code, tell me how bad (or… good?) it is in the comments.
Did you enjoy this post?
Signup to receive a weekly email containing my new posts, curated links, and book reviews.