PHPackages                             adam-paterson/watson-tone-analyzer - 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. [API Development](/categories/api)
4. /
5. adam-paterson/watson-tone-analyzer

ActiveLibrary[API Development](/categories/api)

adam-paterson/watson-tone-analyzer
==================================

IBM Watson Tone Analyzer

721PHP

Since Oct 4Pushed 3mo agoCompare

[ Source](https://github.com/adam-paterson/watson-tone-analyzer)[ Packagist](https://packagist.org/packages/adam-paterson/watson-tone-analyzer)[ RSS](/packages/adam-paterson-watson-tone-analyzer/feed)WikiDiscussions feature/tone-analyzer Synced 4w ago

READMEChangelogDependenciesVersions (8)Used By (0)

IBM Watson - Tone Analyzer
==========================

[](#ibm-watson---tone-analyzer)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5e36d97896efc2720a87f668fb0eae7ee52abb4cab431713492d35a195d38d7b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6164616d2d7061746572736f6e2f776174736f6e2d746f6e652d616e616c797a65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/adam-paterson/watson-tone-analyzer)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/3cde1e90b163722de493e402f921e1cbad7a6dac47c0a6db9101b52463f942cc/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6164616d2d7061746572736f6e2f776174736f6e2d746f6e652d616e616c797a65722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/adam-paterson/watson-tone-analyzer)[![Coverage Status](https://camo.githubusercontent.com/988f80d79102494758a9589b9105b91877a9ff6e82828788edcae4c9e10316f9/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6164616d2d7061746572736f6e2f776174736f6e2d746f6e652d616e616c797a65722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/adam-paterson/watson-tone-analyzer/code-structure)[![Quality Score](https://camo.githubusercontent.com/ceb66d7961a1ff58009ad02a1723b354c7c7a294906360da910a1273ccde8328/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6164616d2d7061746572736f6e2f776174736f6e2d746f6e652d616e616c797a65722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/adam-paterson/watson-tone-analyzer)[![Total Downloads](https://camo.githubusercontent.com/7b49657d01c032671fbaeb422eacc6a92283a6998fd09e3e01330dabe6751f57/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6164616d2d7061746572736f6e2f776174736f6e2d746f6e652d616e616c797a65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/adam-paterson/watson-tone-analyzer)

The IBM Watson™ Tone Analyzer service uses linguistic analysis to detect emotional and language tones in written text. The service can analyze tone at both the document and sentence levels. You can use the service to understand how your written communications are perceived and then to improve the tone of your communications. Businesses can use the service to learn the tone of their customers' communications and to respond to each customer appropriately, or to understand and improve their customer conversations.

**Note:** Request logging is disabled for the Tone Analyzer service. The service neither logs nor retains data from requests and responses, regardless of whether the `X-Watson-Learning-Opt-Out` request header is set.

Install
-------

[](#install)

Via Composer

```
$ composer require adam-paterson/watson-tone-analyzer php-http/guzzle6-adapter
```

**Note:** This library uses an abstraction layer called HTTPlug which decouples it from any HTTP messaging client. To see which adapters are available and learn more visit: .

Usage
-----

[](#usage)

### General Tone

[](#general-tone)

```
/** @var $service IBM\Watson\ToneAnalyzer\Client */
$service = IBM\Watson\ToneAnalyzer\Client::create('username', 'password');

/** @var $analysis \IBM\Watson\ToneAnalyzer\Model\ToneAnalysis */
$analysis = $service->tone()->analyze('My fake plants died because I did not pretend to water them.', [
    'content_language' => 'en',
    'accept_language' => 'en',
    'sentences' => true
]);

/** @var $documentAnalysis \IBM\Watson\ToneAnalyzer\Model\DocumentAnalysis */
$documentAnalysis = $analysis->getDocumentAnalysis();

foreach ($documentAnalysis->getTones() as $tone) {
    /** @var $tone \IBM\Watson\ToneAnalyzer\Model\ToneScore */
    echo $tone->getName() . ': ' . $tone->getScore() . PHP_EOL;
}

// Sadness: 0.6165
// Analytical: 0.829888

$sentenceAnalysis = $analysis->getSentenceAnalysis();

foreach ($sentenceAnalysis as $sentence) {
    echo sprintf('#%d - %s: ', $sentence->getId(), $sentence->getText()) . PHP_EOL;
    foreach ($sentence->getTones() as $tone) {
        echo $tone->getName() . ': ' . $tone->getScore() . PHP_EOL;
    }
}

// #0 - Team, I know that times are tough!
// Analytical: 0.801827
// #1 - Product sales have been disappointing for the past three quarters.
// Sadness: 0.771241
// Analytical: 0.687768
```

### Engagement Tone

[](#engagement-tone)

```
use IBM\Watson\ToneAnalyzer\Model\Utterance;

/** @var $service IBM\Watson\ToneAnalyzer\Client */
$service = IBM\Watson\ToneAnalyzer\Client::create('username', 'password');

$utterances = [
    Utterance::create([
        Utterance::KEY_TEXT => 'Hello, I\'m having a problem with your product.',
        Utterance::KEY_USER => 'customer'
    ]),
    Utterance::create([
        Utterance::KEY_TEXT => 'Sorry to hear that, let me know what\'s going on, please.',
        Utterance::KEY_USER => 'agent'
    ])
];

/** @var $analysis \IBM\Watson\ToneAnalyzer\Model\UtteranceAnalyses */
$analysis = $service->toneChat()->analyze($utterances);

/** @var $documentAnalysis \IBM\Watson\ToneAnalyzer\Model\UtteranceAnalyses */
$utteranceAnalysis = $analysis->getTones();

if (null !== $utteranceAnalysis->getWarning()) {
    echo $utterances->getWarning();
}

foreach ($utterances->getTones() as $tone) {
    /** @var $tone \IBM\Watson\ToneAnalyzer\Model\UtteranceAnalysis */
    echo sprintf('#%d - %s: ', $tone->getId(), $tone->getText()) . PHP_EOL;
    foreach ($tone->getTones() as $utteranceTone) {
        /** @var $utteranceTone \IBM\Watson\ToneAnalyzer\Model\ToneScore */
        echo $utteranceTone->getName() . ': ' . $utteranceTone->getScore() . PHP_EOL;
    }
}

// #0 - Hello, I'm having a problem with your product.
// Polite: 0.686361
// #1 - Sorry to hear that, let me know what's going on, please.
// Polite: 0.92724
// Sympathetic: 0.672499
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](.github/CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email hello\[at\]adampaterson.co.uk instead of using the issue tracker.

Credits
-------

[](#credits)

- [Adam Paterson](https://github.com/adam-paterson)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance54

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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/296c5969d49c166c45bbe6066cc3057d7279a1451f495186ac82de0de9455107?d=identicon)[Adam\_Paterson](/maintainers/Adam_Paterson)

---

Top Contributors

[![adam-paterson](https://avatars.githubusercontent.com/u/1008727?v=4)](https://github.com/adam-paterson "adam-paterson (4 commits)")

### Embed Badge

![Health badge](/badges/adam-paterson-watson-tone-analyzer/health.svg)

```
[![Health](https://phpackages.com/badges/adam-paterson-watson-tone-analyzer/health.svg)](https://phpackages.com/packages/adam-paterson-watson-tone-analyzer)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.3M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172437.8k11](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

94452.6k6](/packages/botman-driver-telegram)

PHPackages © 2026

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