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.
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.
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.
Install the required dependencies
npm install
Open the database
npm run opendb
Populate the database
npm run populate
Run the application
npm run init
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
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.