Code Monkey home page Code Monkey logo

sentiment-analysis's Introduction

Sentiment Analysis Project

This project aims to evaluate the current state of sentiment analysis APIs effectiveness in Online Social Networks. To achieve that, a cross-platfoorm and generic tool is developed that handles the request and responses in a node.js environment. Firstly, we selected three public sentiment polarity-tagged data sets as the baseline of reliable sentiment values. Then we stored these datasets in MongDB and lastly we employed Indico and Google Natural Language (NL) API's.

Datasets Used

DatasetOne (datasetID: 0): 2034 tweets from which 632 are positive and 1402 negative Data Source.

DatasetTwo (datasetID: 1): 797 tweets from which 215 are positive, 406 are negative and 176: neutral DataSource.

DatasetImdb (datasetID:2): 748 sentences from IMDB reviews that 386 are positive and 362 are negative Data Source.

Requirements

To run the project, it is required that the following are installed in your system:

Due to security reasons you must use your own API keys for the APIs to work. To get an API key from Google follow the instructions here To get an API key from Indico follow the instructions here

After getting your API keys add them to the corresponding variables in the config.js file.

Running the project

Install the required dependencies

npm install

Open the database

npm run opendb

Populate the database

npm run populate

Run the application

npm run init

Using the tool with different datasets / APIs

To use your datasets:

In the root folder of the project is the config.js where you can add the specifications of your datasets.

In the datasets object you need to add:

  ...
  datasets: [
    ...
    {
      path: path.join(__dirname, 'THE PATH TO THE DATASET JSON FILE'),
      classifier: {
        negative: NEGATIVE_VALUE FOR CLASSIFIER,
        positive: POSITIVE_VALUE FOR CLASSIFIER
      }
    }
    ...
  ]
  ...

The classifier accepts numbers, strings and number ranges. In case of number ranges a { from: STARTING_VALUE, to: END_VALUE } object should be passed in the classifiers property.

The dataset should be in the JSON format and each text should have the following properties:

  • id: A unique identifier for the text.
  • content: The text.
  • polarity: The sentiment value of the text that is defined in the classifier

To use different APIs

In the config.js file you can define your own APIs to use.

Each API requires:

  • url : The url in which we will post the content
  • polarityName: The name of the polarity that we want to give in our DB. ( e.g. GooglePolarity )
  • dataFormat: A function that takes the content we want to sent to the API and returns an object as it is required by the specific API.
  • responseFormat: A function that takes the response body and returns the polarity value retrieved by the API.
  • classifier: The same as the dataset classifier. It is used to classify the polarity returned by the API.

sentiment-analysis's People

Contributors

annisap avatar

Watchers

James Cloos 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.