Download the PHP package davmixcool/php-sentiment-analyzer without Composer
On this page you can find all versions of the php package davmixcool/php-sentiment-analyzer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download davmixcool/php-sentiment-analyzer
More information about davmixcool/php-sentiment-analyzer
Files in davmixcool/php-sentiment-analyzer
Package php-sentiment-analyzer
Short Description PHP Sentiment Analyzer is a lexicon and rule-based sentiment analysis tool for PHP using VADER (Valence Aware Dictionary and sEntiment Reasoner), matching the reference Python implementation exactly.
License MIT
Homepage https://github.com/davmixcool/php-sentiment-analyzer
Rated 5.00 based on 1 reviews
Informations about the package php-sentiment-analyzer
PHP Sentiment Analyzer
PHP Sentiment Analyzer is a lexicon and rule-based sentiment analysis tool for PHP using VADER (Valence Aware Dictionary and sEntiment Reasoner), matching the reference Python implementation exactly.
Features
- Text
- Emoticon
- Emoji
Requirements
- PHP 8.1 and above
Using PHP below 8.1? Install the
1.xline instead — it is maintained and produces the same scores:composer require davmixcool/php-sentiment-analyzer:^1.3
Contents
- Install
- Modern API
- Simple Usage
- Advanced Usage
- Upgrading
- Relationship to VADER
- License
- Reference
Documentation
- Changelog — release history, including scoring changes
- Migrating from 1.x to 2.0 — breaking changes, and why your scores do not move
- Known divergences — behaviour that differs from reference VADER, documented and pinned by the test suite
Install
Composer
Run the following to include this via Composer
Modern API
Available from 2.0. Returns an immutable result object instead of a bare array.
Labels follow the VADER convention and are exposed as constants, so you can
reclassify without hardcoding: compound >= 0.05 is positive, <= -0.05 is
negative, and anything between is neutral.
Batch analysis preserves your input keys, so results line up with their source rows:
Custom lexicons return a new analyzer — the original is untouched:
withLexicon() rejects multi-word terms and non-numeric values rather than
coercing them. The older updateLexicon() below stays lenient and unchanged.
Simple Usage
Simple Outputs
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:
Advanced Outputs
Upgrading
3.0.0 changes scores. The scoring engine is now a faithful port of reference Python VADER; roughly 45% of test cases moved. Previous behaviour was wrong most importantly in negation, which was applied at about a third of its intended strength.
| Input | 2.x | 3.0 |
|---|---|---|
aint good |
-0.1423 | -0.3412 |
I have never been so happy |
-0.2699 | +0.6948 |
good!!!! |
0.0000 | +0.6209 |
he is a kind person |
0.0000 | +0.5267 |
the shit |
+0.6124 | -0.5574 |
If you store sentiment scores or compare them against thresholds, re-score affected text after upgrading. A threshold tuned against 2.x will behave differently — usually catching more genuinely negative text than before.
If you need score stability, stay on the maintained 2.x line:
Three lines are maintained: 3.x (matches reference VADER), 2.x (scores frozen), 1.x (PHP below 8.1). Full detail in MIGRATION.md.
Relationship to VADER
This package matches reference Python vaderSentiment 3.3.2 exactly.
The lexicon files are byte-identical to upstream, and the rule engine is a faithful port — including reference VADER's own quirks, so that scores agree rather than merely being close. Conformance is verified, not asserted:
That scores a 350-case corpus with both implementations and fails if a single case differs. It runs in CI on every push.
Before 3.0.0 this was not true — the port diverged from reference on 47% of cases, most importantly by applying negation at roughly a third of its intended strength. See MIGRATION.md if you are upgrading from 1.x or 2.x, because your scores will change.
License
The package's source code is licensed under the MIT license.
The bundled sentiment and emoji lexicons in src/Lexicons/ are third-party
data, redistributed from cjhutto/vaderSentiment
under its own MIT license (Copyright (c) 2016 C.J. Hutto). Full attribution and
license text are in NOTICE.md.
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.