🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

sentiment-parser

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sentiment-parser

The sentiment-parser package is used to easily parse sentiments from sentences, using a simple one-liner.

0.0.106
latest
Source
npm
Version published
Weekly downloads
3
50%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status codecov

Sentiment Parser

Description

The sentiment-parser package is used to easily parse sentiments from sentences, using a simple one-liner.

Backend

The package currently uses both an offline package and the IBM Watson API to gather the results. It will also try to guess a best answer, based on the two differing results.

Prepare

You will need to secure credentials from IBM. To do that:

  • Sign up for IBM Cloud.
  • Once you have an accound - go to the Natural Language Understanding service page.
  • Click the "Create" button.
  • Click the "Service Credentials" tab on the Natural Language Understanding page in your IBM Cloud dashboard to view your credentials.
  • Do the same for the ToneAnalyzer service

Initialization

const { Parser } = require('sentiment-parser');
const parser = new Parser();

    parser.setCredentials({
        nlAnalyzer: {
            username: '{your-api-username}',
            password: '{your-api-password}',
        },
        toneAnalyzer: {
            username: '{your-api-username}',
            password: '{your-api-password}',
        }
    });

Usage

parser.parseSentiment(userInput).then(response => {
    // response.score is a value between -1 to 1
    // response.label is "negative" or "positive"
}



parser.parseEmotion(`I hate this`).then(parsedTone => {
    // parsedTone.watsonTone.strongestTone contains the strongest tone
    // parsedTone.watsoneTone.allTones contains an array of all the recognized tones

    // Each tone has a tone_id, tone_name and a score (from 0 to 1)
}

Keywords

watson

FAQs

Package last updated on 11 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts