Skip to content
No description, website, or topics provided.
Java
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gradle/wrapper
src/main/java/net/adeptropolis/sentiments
.gitignore
README.md
build.gradle
gradlew
gradlew.bat
settings.gradle

README.md

CoreNLP RNTN Sentiment Analysis web service?

This is a thin wrapper around CoreNLP's RNTN-based sentiment analyzer that provides a proper rest API for this feature.

Like with most of CoreNLP's processing stages, any text will be segmented into individual sentences before being analyzed. In order to provide a combined score for the full text snippet that has been provided, a weighted sum (by text length) of all sentence sentiments is returned together with the results.

Upon building the jar, all pre-trained language and sentiment models will be automatically downloaded as built-in resources.

Build using the included Gradle wrapper

./gradlew clean b

Run

java -jar -Dserver.port=6868 build/libs/sentiments-0.1.jar

The port is optional. 6868 is the default.

Example usage

Curl:

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"text": "Dig it. Climate change is awesome."}' \
  http://localhost:6868/sentiments

HTTPie:

$ http :6868/sentiments text="Dig it. Climate change is awesome."

Sample Response

HTTP/1.1 200 OK
Content-Type: application/json;charset=utf-8
Date: Tue, 12 Mar 2019 01:18:40 GMT
Transfer-Encoding: chunked

{
    "sentences": [
        {
            "sentenceText": "Dig it.",
            "sentiment": 0
        },
        {
            "sentenceText": "Climate change is awesome.",
            "sentiment": 1
        }
    ],
    "total": 0.6666666666666666
}

Sentiment mappings

All detected sentiments are mapped to a score between -2 and 2. More precisely:

  • -2: Very negative
  • -1: Negative
  • 0: Neutral
  • 1: Positive
  • 2: Very positive
You can’t perform that action at this time.