Socket
Socket
Sign inDemoInstall

sentiment-zh_cn

Package Overview
Dependencies
2
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sentiment-zh_cn

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


Version published
Maintainers
1
Install size
3.20 MB
Created

Readme

Source

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: [ '妈的' ] }

Keywords

FAQs

Last updated on 28 Aug 2016

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