Giter VIP home page Giter VIP logo

sentiment-zh_cn's Introduction

sentiment-zh_cn

基于本地化的AFINN的中文nodejs情感分析库

本项目为sentiment项目的中文fork,基于本地化的AFINN-111词库对中文文本进行情感分析

sentiment-zh_cn在build/目录下提供一份编译AFINN词库的工具和用于保护助语素的源文件。

安装

npm install sentiment-zh_cn

用法

var sentiment = require('sentiment-zh_cn');

var r1 = sentiment('网络不是法外之地。党政机关微信工作群是展示、交流、沟通、讨论工作的平台,属于“公共场所”,党员领导干部是公众人物,一言一行都代表着党和政府的形象。在微信群转发淫秽图片,既破坏了网络环境,危害他人身心健康,又违反了工作纪律、生活纪律,损害了党和政府形象,造成不良影响,必然要受到党纪处理。随即,当地纪委也迅速介入了调查。');
console.dir(r1);

运行结果为:

{ score: -6,
  comparative: -0.08955223880597014,
  tokens:
   [ '网络',
     '不是',
     '法',
     '外', ……],
  words: [ '迅速', '影响', '损害', '违反', '健康', '危害', '破坏' ],
  positive: [ '迅速', '健康' ],
  negative: [ '影响', '损害', '违反', '危害', '破坏' ] }

增加或覆盖词汇评分

在参数列表里增加一个包含自定义词汇评分的字典即可。

var sentiment = require('sentiment-zh_cn');

var r2 = sentiment('他妈的你不想活了?', {'妈的': -10});
console.dir(r2);
{ score: -10,
  comparative: -2,
  tokens: [ '他', '妈的', '你', '不想', '活' ],
  words: [ '妈的' ],
  positive: [],
  negative: [ '妈的' ] }

sentiment-zh_cn's People

Contributors

thisandagain avatar greenkeeperio-bot avatar omegacoleman avatar joshbeckman avatar monteslu avatar micahfulton avatar

Watchers

David Lanz avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.