Giter Site home page Giter Site logo

delvison / sentiment-analysis Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 1.0 292 KB

A simple sentiment analysis program implemented in python that distinguishes positive reviews from negative ones

Python 100.00%
python sentiment-analysis classifier-model nltk

sentiment-analysis's Introduction

###Summary###

This is a sentiment analysis program that can classify a movie critique as either a positive or negative critique. The program is written entirely in python (version 2.7.3) and utilizes components of the Natural Language Toolkit.

###Explanation###

This program utilizes the method of supervised classification. The data set that was used for the training component is listed below. Initially, I had intended to use full critique examples taken from the web but the amount of irrelevant words within these critiques proved for very little accuracy. Instead, I chose to use brief one-line critiques as the training input simply because they were straight to the point and larger fuller critiques can be atomically comprised of these smaller ones. I start by reading my sample input, removing punctuation and any words that contain a length less than 3 from every live. This is mainly to get rid of neutral words such as 'it' and 'the'. The resulting words are then considered to be the features. I generate a training set by utilizing the nltk.classify.apply_features function with my feature extractor function and list of critiques as parameters. The feature extractor of this program takes in a tokenized review, checks what words it contains in relation to the features that were extracted from my sample data and returns a dictionary of this information. The dictionary essentially has boolean values of what words the tokenized review contains in relation to the training feature set. After I have my training set I generate my classifier model by utilizing the nltk.NaiveBayesClassifier.train function with my training set as a parameter. Once I have my classifier model, I am ready to start making predictions. I take a movie critique as an input, tokenize it, extract its features using my feature extractor and pass the list of features into the classifier model's classify function. The result is a label which in this case can be 'positive' or 'negative'.

Heres example of what the feature extractor of this program returns when considering a movie review: Example: “It was a great movie.” --> (tokenize) --> ['It', 'was', 'a', 'great', 'movie'] → pass this set into feature extractor. The return resembles something like this: {'contains(great)' : True, 'contains(movie)' :True 'contains(terrible)': False, (etc)...}

sentiment-analysis's People

Contributors

delvison avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.