Sentiment Analysis API and Front End Client

Simon was trying to apply the AFINN Sentiment Analysis list once again, following a whole playlist of tutorials by Daniel Shiffman. This time things got more complicated as Simon has built a Sentiment Analysis API and attempted to talk to it from a web page by building a simple front end client with HTML and the p5.js library.

He did finish building the text field and the area where he could submit new words and their values to the Sentiment Analysis list.  At the very end of the project he got stuck. When entering a text on his front end client he got all the words from the AFINN list as the response, instead of just the words from the text he entered.

He was thinking about where the bug might be, while riding back home from our vacation.

Unfortuneately this turned out to be a wrong guess. He hasn’t discovered what is wrong as of now.

Advertisements

6 thoughts on “Sentiment Analysis API and Front End Client

  1. amazing. i just use the textblob library for python, its a few lines of code and does the work for me (im not saying the results are better. i havent compared.)

    and somewhere else in the world, simons building a similar library in javascript. (you know i can do javascript, but like java i find it very tedious.) simply amazing! i wouldnt say hes making it “too difficult,” hes just getting deeper into the code. its is a great way to learn.

    for you the non-coder, i will say it like this– at some level it gets down to the simplest instructions that even a computer chip can handle. i bet simon has explained most of this already. languages build functions (with absolutely no fundamental difference to the functions in mathematics, although i think code is more friendly) atop this hardware primitives, until the abstraction of “higher-level language” gives us things like named variables (instead of going to a numeric memory address, we just say “give me ‘auntbea.phonenumber'”) and friendly commands like “print” or “write.”

    coding, at the highest most abstract level– goes one layer deeper than “im going to use the computer and give it each instruction by pointing at something and clicking a menu option” to “im going to go to where that menu is created, and add or take away options from it.

    a user clicks on a part of the screen, the program collects the data and decides which function to call. but the coder simply types in the name of the function itself, and calls it that way. you click on “shutdown” in a menu, and i type in “poweroff” at the command line. these more or less call the same functions, which are in the code of the operating system.

    now for the fun part– what are these functions made of? other functions… its turtles all the way down 🙂 so while i just say: print TextBlob(“analyze this text, please”).sentiment.polarity to get the sentiment rating, simons going another level down, to essentially edit (or even author) the Textblob code i am merely “calling” from my program to do the work.

    and this is the nature of programming. most of the time, it isnt worth getting down more layers into what makes it tick. but someone has to, and you learn more. i can call the builtin “len” command to get the length of “hello world”:

    print len(“hello world”)

    but i can also create my own similar command:

    def length(p):
        c = 0
        for x in p: c = c + 1 # for each letter, increase the count
        return c
    
    print length("hello world") # call your own function, instead of the built-in one

    and thats what simon is doing– instead of just calling a function, he is building one. both are “coding.” after all, most of the functions that you call are themselves a group of function calls. in math its no different– what is a mathematical function made of? its made of numeric functions (operators, proceses, etc.) 🙂

    not to suggest that you dont appreciate what simon is doing, but i hope this in some way helps you appreciate it a little further. in many ways it is standard coding– but what hes doing is more advanced (and more educational) than what is necessary to simply get the job done 🙂 –major cool points for simon.

    Liked by 1 person

    1. Thank you! I wonder how much of this is due to Daniel Shiffman’s style he is learning from. Although he has been learning from many platforms I believe Daniel has had major influence on him. And has taught him English! Maybe I should write him an e-mail about Simon 🙂

      Liked by 1 person

  2. line 19: httpPost(‘analyze/’), data, ‘json’, dataPosted, postErr); // but what happens if he changes data to just: txt

    depending on how the library hes using (especially the httpPost function) handles typing, the change might not even work. (js is a weakly typed language, but a library could simulate stronger typing.) did he figure it out yet? also, its painful to try to read code from youtube 😦 it keeps moving, and then you pause it… it will certainly keep most people from copying his code though.

    Like

    1. No, he hasn’t. I’ll see if he wants to share the whole thing on GitHub tomorrow. But the thing is, he gets carried away with a different project very quickly and then it’s difficult to get him to do anything for an old project where he got stuck, unless he himself decides so at a later stage. He does so many things per day that I sometimes get seriously behind with posting them. Like this project is already a couple days old and I only posted it yesterday. In fact Simon spent today mostly messing around with Android Studio on Windows, something totally different 🙂

      Liked by 1 person

      1. thats ok, so long as hes not getting paid to work on them.

        seriously though, hes probably learning more the way hes doing it, than if he really buckled down and tried to finish every project. he will go back to working on the ones that really matter– your creation of portfolios can only help in that regard 🙂

        Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s