Showing posts with label node. Show all posts
Showing posts with label node. Show all posts

Incorporating a Dynamic Word Cloud into a Searchable World Tweet Map

This is a quick note about a simple feature added to the searchable world tweet map visualization. Namely, the wordcloud2.js project by TimDream was incorporated into this visualization, with the word cloud updated dynamically as tweets are received based on the search.

When you're watching tweets streaming by, your eye can kind of pick out patterns, but the word cloud gives a somewhat better (and sometimes insightful) summarization.

A Dynamic Word Cloud added to a
Searchable World Tweetmap
(word cloud implementation based on
Tim Dream's wordcloud2.js project)

At this point, nothing fancy is done to handle a moving time window, bigrams, custom colors, etc. Nevertheless, right off the bat it seemed to add an interesting extra dimension to this visualization.

Node and emojis - No Smiley?

I have been playing recently with a world tweet map (available here, login via twitter required), and one of the things I noticed last weekend was that all of the special characters used in tweets were not being displayed correctly. This stinks when displaying tweets, because they occur all the time. Instead of the smileys and all the other silly things, there were just square boxes displayed.

It turns out that there seems to be an issue sometimes with either node.js or Chrome with emojis. I haven't researched this completely, but one thing that seemed to help out here was to use the emojis node module by fengmk2 when putting showing the relevant html. Using this module is really simple - just load it via require and call emoji.unitfiedToHTML(text). As you can see in the example below, this does not seem to work for all emojis. The node module uses a sprite sheet, so there are likely a few still missing. And it still seems to be quirky in an svg text element in Chrome. However, it's better than having only little squares across the board.

Getting a few happy emojis to
display in a node app
via the emojis node module.
You can see it in use at this world tweet map app

I was looking at the app with the Safari browser, and I didn't see the same issues, which is why I think there might be something Chrome-specific going on here.

And maybe there's a 100% solution available - I haven't found it yet.

Sorry State of Sentiment Analysis?

While playing around with the searchable tweet map I brought back to life via node.js so that it could work with the twitter 1.1 api, I figured it would be cool to see if it were possible to add a sentiment analysis component to it. Maybe I could subtly color-code the tweets regarding sentiment.

It turns out there are really easy ways to do get an estimate of sentiment with just a few lines of code and one of the node sentiment modules, but the ones I found all were based on single-word approaches. All seemed to use AFINN from 2011 that of course can be wrong a lot of the time when sentiment is derived from multiple words together, rather than summing up individual word scores. And that is true a lot of the time.

It's a hard problem, I guess, but I was disappointed.

I came across a recent open-source engine by Stanford's NLP group, but they seemed to mainly just use Amazon's Mechanical Turk to get the sentiment values for movie reviews from a few years ago, coupled with a lot of fancy stats/methods to derive a model. This is in java, and is huge. Not a few lines in node.js (unless you hit their demo web page every time you want to get the sentiment for a tweet - which I wouldn't recommend).

After a little bit of googling and reading various recent papers I even more disappointed with where things seem to be.

Of course, twitter is sitting on the goldmine.

I seem to recall that sometimes twitter will return some sort of sentiment value in the guts of the tweet json, but not all the time. The fact that they don't just return this all the time tells me that they probably don't have any sort of model that can estimate these sentiment quantities quickly. Or I guess they could be holding back on giving those values out freely, but that seems a bit counter to their general openness.

Nevertheless, I had assumed we were farther along in this area. Hopefully, I'm missing something trivial here.

RedHat's OpenShift + Node/Express/Mongoose/Passport on Free Tier - No Credit Card Required

As part of setting up an application that used twitter/google/github for authentication, I began playing with some of the cloud providers. I was going to use Heroku, but to use mongodb apparently required a credit card, even though there are not supposed to be any charges. Now, they didn't say it would cost anything, but I did not want to run the risk of having it start charging anyway if I somehow blew through the free tier limits.

So, I then saw that RedHat's OpenShift platform also offered a test drive of mongo in your node app, and it did not require a credit card for that. And sure enough, using just my email address, I got a little app using mongo to work, with user authentication via twitter (OAuth) using passport.js. This little app is by Madhusudhan Srinivasa and is on github.

Popular Posts