Con el paso del huracán María, ha sido sumamente importante poder tener información actualizada de las sucursales que estén abiertas. El grupo de Popular ha estado publicando diariamente una lista de sucursales abiertas en Facebook.
Para facilitar la localización de estas sucursales, una idea es que sería mejor poder visualizarlas en un Google Map. Para hacer esto, escribí un programa en Node.js que básicamente coge la información del último post de Facebook, y hace un "cross-reference" con la información disponible en el "Branch Locator" de la página de Popular. Esto es necesario porque ahí está la latitud y longitud de cada sucursal abierta.
Este es el resultado final:
Para los que son "techies" y les interesa saber como funciona el código, aquí les incluyo unos screenshots. Como ven, el código es bastante sencillo y me tomó como 20 minutos poder tenerlo todo listo:
Una vez se crea la data, el próximo paso es subirlo a Google Maps. Esta parte es bastante sencilla. Con un CSV ya creado, vas a http://google.com/mymaps y de ahí creas un mapa nuevo. En el mapa creas un "layer" nuevo, y le das a Import para importar la data del CSV y "pa fuera"! :)
How Social Business Accelerates Innovation in the Workplace from the perspective of a Millennial
Showing posts with label node.js. Show all posts
Showing posts with label node.js. Show all posts
Tuesday, October 3, 2017
Wednesday, May 31, 2017
Measuring Twitter Sentiment with Watson Natural Language Understanding
It's been a couple of months now since my last project on Node.js . The other day I wanted to set up an example of a dashboard with sentiment coming from Twitter around a keyword.
To keep things simple, I used IFTTT to export tweets to a CSV file. With that I could then use Watson's libraries to measure sentiment. To start, I created a new trial account on BlueMix. Once there, go to Services - Watson - Create Watson service. Once there pick Natural Language Understanding and it will create an instance of the service. This Watson service helps to make sense out of pretty much any text.
The screen should look like this:
With the tweets now in a CSV and Watson at the ready, it was time to put the pieces together with node.js. I took advantage of the following node.js libraries: csv-parser, csv-write-stream, watson-developer-cloud.
Let me walk through the code (which I'll put on Github soon). First, import and setup the libraries (you get the Watson credentials directly from Bluemix and my preference is to store them as environment variables):
Next, read the CSV, parse it, measure it and write a new CSV out all with this one line of code:
The function sentimentFromWatson is key above. That function takes advantage of the Watson library already available. Here's what that function looks like:
And that's it! In total, you have a quick sample in 20-30 lines of code to measure sentiment from Twitter. Below is the graphic that I created. In a span of a weekend, the keyword that I was monitoring had some positive tweets and others that were negative. Overall, that weekend was pretty neutral.
(Note: the free plan for Watson Natural Language Understanding gives you 1,000 calls / day. If you expect more than 1,000 tweets / day you'll need a paid plan).
Overall, this took me about 30 minutes to put together and a bit of troubleshooting. If you haven't played with Node.js and Watson yet, go for it!
To keep things simple, I used IFTTT to export tweets to a CSV file. With that I could then use Watson's libraries to measure sentiment. To start, I created a new trial account on BlueMix. Once there, go to Services - Watson - Create Watson service. Once there pick Natural Language Understanding and it will create an instance of the service. This Watson service helps to make sense out of pretty much any text.
The screen should look like this:
With the tweets now in a CSV and Watson at the ready, it was time to put the pieces together with node.js. I took advantage of the following node.js libraries: csv-parser, csv-write-stream, watson-developer-cloud.
Let me walk through the code (which I'll put on Github soon). First, import and setup the libraries (you get the Watson credentials directly from Bluemix and my preference is to store them as environment variables):
Next, read the CSV, parse it, measure it and write a new CSV out all with this one line of code:
The function sentimentFromWatson is key above. That function takes advantage of the Watson library already available. Here's what that function looks like:
And that's it! In total, you have a quick sample in 20-30 lines of code to measure sentiment from Twitter. Below is the graphic that I created. In a span of a weekend, the keyword that I was monitoring had some positive tweets and others that were negative. Overall, that weekend was pretty neutral.
(Note: the free plan for Watson Natural Language Understanding gives you 1,000 calls / day. If you expect more than 1,000 tweets / day you'll need a paid plan).
Overall, this took me about 30 minutes to put together and a bit of troubleshooting. If you haven't played with Node.js and Watson yet, go for it!
Subscribe to:
Posts (Atom)





