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

negaposi-analyzer-ja

v1.0.1

Published

形態素解析したtokenからネガティブ/ポジティブを判定したスコアを返すJavaScriptライブラリ

Downloads

19

Readme

negaposi-analyzer-ja Build Status

形態素解析したテキストからネガティブ/ポジティブ(単語感情極性)を判定したスコアを返すJavaScriptライブラリ

Install

Install with npm:

npm install negaposi-analyzer-ja

辞書

辞書には単語感情極性対応表を利用します。 このモジュールには辞書のダウンロードスクリプトが同梱されているので、モジュールをインストール後次のコマンドでダウンロードできます。

./node_modules/.bin/download-negaposi-dict

Usage

CLI

echo "これは良い文章だと思います。" | negaposi-analyzer
# 0.08096107836464397

Node.js

このライブラリ自体は形態素解析をしていません。 形態素解析した結果のtoken配列を引数として受け取ります。

形態素解析にはkuromoji.js(またはラッパーであるkuromojin)を想定しています。

const assert = require("assert");
const kuromojin = require("kuromojin");
const analyze = require("negaposi-analyzer-ja");
kuromojin("これは良い文章だと思います。").then(tokens => {
    const score = analyze(tokens);
    assert(score === 0.0899567537384933);
});

analyze(tokens: Object[], options?: Object): number

kuromojiの形態素解析した結果のtoken配列(tokens)を受け取り、スコアを返します。 辞書には単語(品詞付き)毎に-1から1の範囲のスコアが設定されています。

analyzeの返すスコアは各単語のスコアを合計をtokenの数で割った値です。

Options

const defaultOptions = {
    // 辞書にない単語のスコア
    unknownWordRank: 0,
    // ポジティブな単語に対する補正値(スコアに乗算)
    positiveCorrections: 1,
    // ネガティブな単語に対する補正値(スコアに乗算)
    negativeCorrections: 5122 / 49983,
    // 辞書の配列
    posiNegaDict: require("../dict/pn_ja.dic.json")
};

デフォルトではネガティブ単語に補正値をかけています。 理由としては、単語感情極性対応表にはネガティブな単語の割合が多いため、 補正値なしでは大体のケースがネガティブと判断されるためです。

const posiNegaRatio = {
    posi: 5122,
    nega: 49983,
    zero: 20
};

Related

Changelog

See Releases page.

Running tests

Install devDependencies and Run npm test:

npm i -d && npm test

Contributing

Pull requests and stars are always welcome.

For bugs and feature requests, please create an issue.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

License

MIT © azu

Dictionary

This library not includes the dictionary, but includes download tool.

単語感情極性対応表

高村大也, 乾孝司, 奥村学
"スピンモデルによる単語の感情極性抽出", 情報処理学会論文誌ジャーナル, Vol.47 No.02 pp. 627--637, 2006.
Hiroya Takamura, Takashi Inui, Manabu Okumura,
"Extracting Semantic Orientations of Words using Spin Model", In Proceedings of the 43rd Annual Meeting of the Association for Computational Linguistics (ACL2005) , pages 133--140, 2005.