sentiment-deftbyte

5.0.2 • Public • Published

sentiment-deftbyte

AFINN-based sentiment analysis for Node.js

Forked from Sentiment by thisandagain https://github.com/thisandagain/sentiment

Added Feature

1. Custom tokenization

You can add a custom function for creating tokens by adding customLabels and customTokenization in registerLanguage method

const Sentiment = require('./lib/index')
const sentiment = new Sentiment()
// require the custom tokenizetion function
const customFunction = require('./custom-tokenization') 

const idLanguage = {
  labels: {
     'berhasil': 3
     },
  customLabels: {
    "kasih sayang": 2
    "bertepuk tangan": 2
  },
  customTokenization: customFunction
};
sentiment.registerLanguage('id', idLanguage)

const analyzeOptions = {
  language: 'id'
}
const text = 'saat saya berhasil mengutarakan rasa kasih sayang ke dia, semua orang bertepuk tangan'
const result = sentiment.analyze(text, analyzeOptions)
console.dir(result)

The result will be:

{ score: 7,
  comparative: 0.6363636363636364,
  tokens:
   [ 'saat',
     'saya',
     'berhasil',
     'mengutarakan',
     'rasa',
     'kasih sayang',
     'ke',
     'dia',
     'semua',
     'orang',
     'bertepuk tangan' ],
  words: [ 'bertepuk tangan', 'kasih sayang', 'berhasil' ],
  positive: [ 'bertepuk tangan', 'kasih sayang', 'berhasil' ],
  negative: [] }

/sentiment-deftbyte/

    Package Sidebar

    Install

    npm i sentiment-deftbyte

    Weekly Downloads

    1

    Version

    5.0.2

    License

    MIT

    Unpacked Size

    455 kB

    Total Files

    47

    Last publish

    Collaborators

    • gilang0293