百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

sentimental

> 编程语言
开源

使用 Ruby 进行简单的情感分析

465 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

使用 Ruby 进行简单的情感分析

sentimental

Simple sentiment analysis with Ruby

How it works

Sentences are tokenized and tokens are assigned a numerical score for their average sentiment. The total score is then used to determine the overall sentiment in relation to the threshold.

For example, the default threshold is 0.0. If a sentence has a score of 0, it is deemed "neutral". Higher than the thresold is "positive", lower is "negative".

If you set the threshold to a non-zero amount, e.g. 0.25:

  • Positive scores are > 0.25
  • Neutral scores are -0.25 - 0.25
  • Negative scores are :positive

analyzer.sentiment 'I like ruby' #=> :neutral

analyzer.sentiment 'I really like ruby' #=> :positive

You can make new analyzers with individual thresholds:

analyzer = Sentimental.new(threshold: 0.9) analyzer.sentiment 'I love ruby' #=> :positive

analyzer.sentiment 'I like ruby' #=> :neutral

analyzer.sentiment 'I really like ruby' #=> :neutral

Get the numerical score of a string:

analyzer.score 'I love ruby' #=> 0.925


## Sentiment dictionaries

These are currently plain-text files containing whitespace-separated
scores and tokens, e.g.:

    1.0 Awesome
    0.0 Meh
    -1.0 Horrible

## N-grams

You can parse n-grams of words by specifying their max size in the initializer:

Sentimental.new(ngrams: 4)


The dictionary must have this format:

    1.0 very happy
    -2.0 no
    0.0 meh

## Installation

    gem install sentimental

## License

MIT License

## Credits

Based largely on Christopher MacLellan's script:
https://github.com/cmaclell/Basic-Tweet-Sentiment-Analyzer

## Changes
- 2013-10-13 Adding :-) to slang

Issues· 5 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言