otifsolutions/php-sentiment-analysis
Composer 安装命令:
composer require otifsolutions/php-sentiment-analysis
包简介
Php Sentiment Analysis allows user to analyze sentiments from a text statement
README 文档
README
Install via Composer
Using Composer (Recommended)
You can run the following command in the root directory of your project:
composer require otifsolutions/php-sentiment-analysis
Usage
-
Php Sentiment Analysis allows to analyze a text statement if it is positive or negative. e.g. comment on any post.
Sentiment::make()->analyze($value);
- Where $value is the statement to be analyzed.
-
Statement may contain labels, emojis and negators.
- Labels are words statement contains e.g.
corruption,boycott. - Emoji e.g.
😍,💖. - Negators are words that negate something e.g.
doesnt,not.
- Labels are words statement contains e.g.
-
We use following methods
-
getTokens- This method separate the words from the given statement and returns all words.
-
getDataSet- This method has dataset.
- Labels, emojis and negators already stored in the dataset, which have a positive or negative value.
- For example
"fun": 4, "funeral": -1,
-
This example demonstrates the usage of Php Sentiment Analysis,
Sentiment::make()->analyze('She is famous, but she hates others.');
{
"score": -1,
"comparative": -0.14285714285714285,
"calculation": [
{"she": 0},{"is": 0},{"famous": 2},{"but": 0},{"she": 0},{"hates": -3},{"others": 0}
],
"tokens": [
"she","is","famous","but","she","hates","others"
],
"positive": [
"famous"
],
"negative": [
"hates"
]
}
| Option | Description |
|---|---|
score |
Positive or negative value after analysis of given statement. |
tokens |
Tokens are the separated words in a Statement. |
comparative |
Value received when score is divided by count of token. |
calculation |
Words in an array with a positive or negative value, if the word exists in dataset the value will be positive or negative otherwise value will be zero. |
positive |
Shows all positive words from the statement. |
negative |
shows all negative words from the statement. |
otifsolutions/php-sentiment-analysis 适用场景与选型建议
otifsolutions/php-sentiment-analysis 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 545 次下载、GitHub Stars 达 4, 最近一次更新时间为 2020 年 06 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 otifsolutions/php-sentiment-analysis 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 otifsolutions/php-sentiment-analysis 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 545
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-06-02