{"id":21664511,"url":"https://github.com/davmixcool/php-sentiment-analyzer","last_synced_at":"2025-04-05T08:06:15.321Z","repository":{"id":43211219,"uuid":"146601310","full_name":"davmixcool/php-sentiment-analyzer","owner":"davmixcool","description":"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).","archived":false,"fork":false,"pushed_at":"2022-10-15T06:37:10.000Z","size":165,"stargazers_count":139,"open_issues_count":0,"forks_count":37,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T07:05:41.819Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davmixcool.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":["https://www.buymeacoffee.com/iamdavidoti"]}},"created_at":"2018-08-29T13:07:41.000Z","updated_at":"2025-03-23T13:08:51.000Z","dependencies_parsed_at":"2022-08-21T05:40:27.640Z","dependency_job_id":null,"html_url":"https://github.com/davmixcool/php-sentiment-analyzer","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davmixcool%2Fphp-sentiment-analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davmixcool%2Fphp-sentiment-analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davmixcool%2Fphp-sentiment-analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davmixcool%2Fphp-sentiment-analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davmixcool","download_url":"https://codeload.github.com/davmixcool/php-sentiment-analyzer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305933,"owners_count":20917208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-25T10:39:30.533Z","updated_at":"2025-04-05T08:06:15.295Z","avatar_url":"https://github.com/davmixcool.png","language":"PHP","funding_links":["https://www.buymeacoffee.com/iamdavidoti"],"categories":["Natural Language Processing"],"sub_categories":["Recommended core stack"],"readme":"# PHP Sentiment Analyzer\n\nPHP 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\\).\n\n[![GitHub license](https://img.shields.io/github/license/davmixcool/php-sentiment-analyzer.svg)](https://github.com/davmixcool/php-sentiment-analyzer/blob/master/LICENSE) [![GitHub issues](https://img.shields.io/github/issues/davmixcool/php-sentiment-analyzer.svg)](https://github.com/davmixcool/php-sentiment-analyzer/issues) [![Stable](https://poser.pugx.org/davmixcool/php-sentiment-analyzer/v/stable.svg)](https://poser.pugx.org/davmixcool/php-sentiment-analyzer/v/stable.svg) [![Download](https://poser.pugx.org/davmixcool/php-sentiment-analyzer/d/total.svg)](https://poser.pugx.org/davmixcool/php-sentiment-analyzer/d/total.svg) [![Twitter](https://img.shields.io/twitter/url/https/github.com/davmixcool/php-sentiment-analyzer.svg?style=social)](https://twitter.com/intent/tweet?text=Wow:\u0026url=https%3A%2F%2Fgithub.com%2Fdavmixcool%2Fphp-sentiment-analyzer)\n\n## Features\n\n* Text\n* Emoticon\n* Emoji\n\n## Requirements\n\n* PHP 5.5 and above\n\n## Steps:\n\n* [Install](./#install)\n* [Usage](./#usage)\n* [Stargazers](./#stargazers)\n* [Forkers](./#forkers)\n* [License](./#license)\n* [Reference](./#reference)\n\n### Install\n\n**Composer**\n\nRun the following to include this via Composer\n\n```text\ncomposer require davmixcool/php-sentiment-analyzer\n```\n\n### Simple Usage\n\n```php\nUse Sentiment\\Analyzer;\n$analyzer = new Analyzer(); \n\n$output_text = $analyzer-\u003egetSentiment(\"David is smart, handsome, and funny.\");\n\n$output_emoji = $analyzer-\u003egetSentiment(\"😁\");\n\n$output_text_with_emoji = $analyzer-\u003egetSentiment(\"Aproko doctor made me 🤣.\");\n\nprint_r($output_text);\nprint_r($output_emoji);\nprint_r($output_text_with_emoji);\n```\n\n### Simple Outputs\n\n```text\nDavid is smart, handsome, and funny. ---------------- ['neg'=\u003e 0.0, 'neu'=\u003e 0.337, 'pos'=\u003e 0.663, 'compound'=\u003e 0.7096]\n\n😁 ------------------- ['neg' =\u003e 0, 'neu' =\u003e 0.5, 'pos' =\u003e 0.5, 'compound' =\u003e 0.4588]\n\nAproko doctor made me 🤣 ------------- ['neg' =\u003e 0, 'neu' =\u003e 0.714, 'pos' =\u003e  0.286, 'compound' =\u003e 0.4939]\n```\n\n### Advanced Usage\n\nYou can now dynamically update the VADER \\(Valence\\) lexicon on the fly for words that are not in the dictionary. See the Example below:\n\n```php\nUse Sentiment\\Analyzer;\n\n$sentiment = new Sentiment\\Analyzer();\n\n$strings = [\n    'Weather today is rubbish',\n    'This cake looks amazing',\n    'His skills are mediocre',\n    'He is very talented',\n    'She is seemingly very agressive',\n    'Marie was enthusiastic about the upcoming trip. Her brother was also passionate about her leaving - he would finally have the house for himself.',\n    'To be or not to be?',\n];\n\n//new words not in the dictionary\n$newWords = [\n    'rubbish'=\u003e '-1.5',\n    'mediocre' =\u003e '-1.0',\n    'agressive' =\u003e '-0.5'\n];\n\n//Dynamically update the dictionary with the new words\n$sentiment-\u003eupdateLexicon($newWords);\n\n//Print results\nforeach ($strings as $string) {\n    // calculations:\n    $scores = $sentiment-\u003egetSentiment($string);\n    // output:\n    echo \"String: $string\\n\";\n    print_r(json_encode($scores));\n    echo \"\u003cbr\u003e\";\n}\n```\n\n### Advanced Outputs\n\n```text\nWeather today is rubbish  ------------- {\"neg\":0.455,\"neu\":0.545,\"pos\":0,\"compound\":-0.3612} \n\nThis cake looks amazing  ------------- {\"neg\":0,\"neu\":0.441,\"pos\":0.559,\"compound\":0.5859}\n\nHis skills are mediocre  ------------- {\"neg\":0.4,\"neu\":0.6,\"pos\":0,\"compound\":-0.25}\n\nHe is very talented  ------------- {\"neg\":0,\"neu\":0.457,\"pos\":0.543,\"compound\":0.552}\n\nShe is seemingly very agressive  ------------- {\"neg\":0.338,\"neu\":0.662,\"pos\":0,\"compound\":-0.2598}\n\nMarie 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}\n\nString: To be or not to be?  ------------- {\"neg\":0,\"neu\":1,\"pos\":0,\"compound\":0}\n```\n\n### Stargazers\n\n[![Stargazers repo roster for @davmixcool/php-sentiment-analyzer](https://reporoster.com/stars/davmixcool/php-sentiment-analyzer)](https://github.com/davmixcool/php-sentiment-analyzer/stargazers)\n\n### Forkers\n\n[![Forkers repo roster for @davmixcool/php-sentiment-analyzer](https://reporoster.com/forks/davmixcool/php-sentiment-analyzer)](https://github.com/davmixcool/php-sentiment-analyzer/network/members)\n\n### License\n\nThis package is licensed under the [MIT license](https://github.com/davmixcool/php-sentiment-analyzer/blob/master/LICENSE).\n\n### Reference\n\nHutto, C.J. \u0026 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.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavmixcool%2Fphp-sentiment-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavmixcool%2Fphp-sentiment-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavmixcool%2Fphp-sentiment-analyzer/lists"}