davmixcool/php-sentiment-analyzer
Composer 安装命令:
composer require davmixcool/php-sentiment-analyzer
包简介
PHP Sentiment Analyzer is a lexicon and rule-based sentiment analysis tool that is used to understand sentiments in a sentence using VADER (Valence Aware Dictionary and sentiment Reasoner).
README 文档
README
PHP Sentiment Analyzer is a lexicon and rule-based sentiment analysis tool that is used to understand sentiments in a sentence using VADER (Valence Aware Dictionary and sentiment Reasoner).
Features
- Text
- Emoticon
- Emoji
Requirements
- PHP 5.5 and above
Steps:
Install
Composer
Run the following to include this via Composer
composer require davmixcool/php-sentiment-analyzer
Simple Usage
Use Sentiment\Analyzer; $analyzer = new Analyzer(); $output_text = $analyzer->getSentiment("David is smart, handsome, and funny."); $output_emoji = $analyzer->getSentiment("😁"); $output_text_with_emoji = $analyzer->getSentiment("Aproko doctor made me 🤣."); print_r($output_text); print_r($output_emoji); print_r($output_text_with_emoji);
Simple Outputs
David is smart, handsome, and funny. ---------------- ['neg'=> 0.0, 'neu'=> 0.337, 'pos'=> 0.663, 'compound'=> 0.7096]
😁 ------------------- ['neg' => 0, 'neu' => 0.5, 'pos' => 0.5, 'compound' => 0.4588]
Aproko doctor made me 🤣 ------------- ['neg' => 0, 'neu' => 0.714, 'pos' => 0.286, 'compound' => 0.4939]
Advanced Usage
You can now dynamically update the VADER (Valence) lexicon on the fly for words that are not in the dictionary. See the Example below:
Use Sentiment\Analyzer; $sentiment = new Sentiment\Analyzer(); $strings = [ 'Weather today is rubbish', 'This cake looks amazing', 'His skills are mediocre', 'He is very talented', 'She is seemingly very agressive', 'Marie was enthusiastic about the upcoming trip. Her brother was also passionate about her leaving - he would finally have the house for himself.', 'To be or not to be?', ]; //new words not in the dictionary $newWords = [ 'rubbish'=> '-1.5', 'mediocre' => '-1.0', 'agressive' => '-0.5' ]; //Dynamically update the dictionary with the new words $sentiment->updateLexicon($newWords); //Print results foreach ($strings as $string) { // calculations: $scores = $sentiment->getSentiment($string); // output: echo "String: $string\n"; print_r(json_encode($scores)); echo "<br>"; }
Advanced Outputs
Weather today is rubbish ------------- {"neg":0.455,"neu":0.545,"pos":0,"compound":-0.3612}
This cake looks amazing ------------- {"neg":0,"neu":0.441,"pos":0.559,"compound":0.5859}
His skills are mediocre ------------- {"neg":0.4,"neu":0.6,"pos":0,"compound":-0.25}
He is very talented ------------- {"neg":0,"neu":0.457,"pos":0.543,"compound":0.552}
She is seemingly very agressive ------------- {"neg":0.338,"neu":0.662,"pos":0,"compound":-0.2598}
Marie was enthusiastic about the upcoming trip. Her brother was also passionate about her leaving - he would finally have the house for himself. ------------- {"neg":0,"neu":0.761,"pos":0.239,"compound":0.765}
String: To be or not to be? ------------- {"neg":0,"neu":1,"pos":0,"compound":0}
Stargazers
Forkers
License
This package is licensed under the MIT license.
Reference
Hutto, C.J. & Gilbert, E.E. (2014). VADER: A Parsimonious Rule-based Model for Sentiment Analysis of Social Media Text. Eighth International Conference on Weblogs and Social Media (ICWSM-14). Ann Arbor, MI, June 2014.
davmixcool/php-sentiment-analyzer 适用场景与选型建议
davmixcool/php-sentiment-analyzer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 170.71k 次下载、GitHub Stars 达 134, 最近一次更新时间为 2018 年 08 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「social」 「nlp」 「machine learning」 「ai」 「Deep learning」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 davmixcool/php-sentiment-analyzer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 davmixcool/php-sentiment-analyzer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 davmixcool/php-sentiment-analyzer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Interface for Babel Street Text Analytics
Simple Sharing generates social media share links within CP entry pages, allowing you to quickly & easily share entries.
LinkedIn integration for Social
Magento 2 Social Login extension is designed for quick login to your Magento 2 store without procesing complex register steps
A modern PHP client for the Hugging Face Inference API with full type safety and comprehensive model support
Alibaba Cloud Nlp SDK for PHP
统计信息
- 总下载量: 170.71k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 136
- 点击次数: 44
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-08-29