npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sentiment-zh_cn_web

v1.0.2

Published

基于本地化的AFINN的中文nodejs情感分析库with browser && electron support

Downloads

6

Readme

sentiment-zh_cn_web

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

本项目为sentiment-zh_cn的web/browser的fork,sentiment-zh_cn项目为sentiment项目的中文fork。

因为sentiment-zh_cn项目中的node-analyzer依赖无法在webpack环境下使用,所以将相关分词依赖包换成segmentit

以下描述搬运自sentiment-zh_cn,只是将包名sentiment-zh_cn替换为sentiment-zh_cn_web


基于本地化的AFINN-111词库对中文文本进行情感分析

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

安装

npm install sentiment-zh_cn_web

用法

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

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

运行结果为:

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

增加或覆盖词汇评分

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

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

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