PHPackages                             mitmelon/sentiment - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mitmelon/sentiment

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mitmelon/sentiment
==================

Sentiment is a sentiment classifier. It uses a model of words that are categorised as positive, negative or neutral, and a naive bayes algorithm to calculate sentiment. To improve accuracy, Sentiment removes 'noise' words.

222Hack

Since Oct 15Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/mitmelon/Sentiment)[ Packagist](https://packagist.org/packages/mitmelon/sentiment)[ RSS](/packages/mitmelon-sentiment/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Sentiment
=========

[](#sentiment)

Sentiment analysis library for mood detections from text.

Sentiment is a sentiment classifier. It uses a model of words that are categorised as positive, negative or neutral, and a naive bayes algorithm to calculate sentiment. To improve accuracy, Sentiment removes 'noise' words.

Install:
--------

[](#install)

Use composer to install

```
composer require mitmelon/sentiment:dev-master@dev
```

Initialise :
------------

[](#initialise-)

```
require_once __DIR__."/vendor/autoload.php";

// Initialize library class
$sentiment = new Sentiment\Sentiment();
```

Check for sentiment:
--------------------

[](#check-for-sentiment)

```
//Beutifies your result
if (PHP_SAPI != 'cli') {
	echo "";
}
//List of sentences to check
$sentences = array('The boy is very bad', 'I love that girl', 'Some people said i need to take a nap');

foreach ($sentences as $sentence) {
    $scores = $sentiment->score($sentence);
    $class = $sentiment->categorise($sentence);

	// return:
	echo "Sentence : $sentence\n";
    echo "Category: $class\n";
    echo "Scores: ";
    print_r($scores);
	echo "\n";
}
```

Train existing model:
---------------------

[](#train-existing-model)

```
/**
 * You can train the existing model with new word list
 * Train existing model with word list
 * @param string $class model name to train. Anyone on the list - 'pos', 'neg', 'neu'
 * @return array $wordList training set which must be in one dimensional array
*/
$modelName = 'pos';
$wordList = array('love', 'good');// add your wordlist
$train = $sentiment->training($modelName, $wordList);
echo $train;
```

Future Update
=============

[](#future-update)

- Similey recognitions

License
=======

[](#license)

Released under the MIT license.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance54

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/1f05a05a056e93b9cd6513702b8c1af6f6ae71a9c8e288230ec1c10c6ffa3719?d=identicon)[mitmelon](/maintainers/mitmelon)

---

Top Contributors

[![mitmelon](https://avatars.githubusercontent.com/u/55149512?v=4)](https://github.com/mitmelon "mitmelon (6 commits)")

### Embed Badge

![Health badge](/badges/mitmelon-sentiment/health.svg)

```
[![Health](https://phpackages.com/badges/mitmelon-sentiment/health.svg)](https://phpackages.com/packages/mitmelon-sentiment)
```

###  Alternatives

[beyondit/opencart-extension-installer

Custom Composer Installer for installing OpenCart Extensions

1020.4k3](/packages/beyondit-opencart-extension-installer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
