Socket
Socket
Sign inDemoInstall

sentiment-parser

Package Overview
Dependencies
89
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

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.


Version published
Weekly downloads
4
Maintainers
1
Created
Weekly downloads
 

Readme

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:

  1. Sign up for IBM Cloud.
  2. Once you have an accound - go to the Natural Language Understanding service page.
  3. Click the "Create" button.
  4. Click the "Service Credentials" tab on the Natural Language Understanding page in your IBM Cloud dashboard to view your credentials.
  5. 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

FAQs

Last updated on 11 Jun 2018

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc