2017 © Pedro Peláez
 

library caroline

AFINN-based sentiment analysis

image

certifiedwebninja/caroline

AFINN-based sentiment analysis

  • Friday, September 19, 2014
  • by stnmrshx
  • Repository
  • 2 Watchers
  • 15 Stars
  • 27 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 4 Versions
  • 8 % Grown

The README.md

Caroline - Sentimental Analysis

Build Status Coverage Status Software License Packagist Version Total Downloads, (*1)

Sentiment analysis tool for PHP based on the AFINN-111 wordlist., (*2)

Install

composer require certifiedwebninja/caroline:1.0.0

Simple Example

use CertifiedWebNinja\Caroline\Analysis;

$caroline = new Analysis;

$result = $caroline->analyze('Hey you worthless scumbag');

echo 'Score: '.$result->getScore().PHP_EOL;
echo 'Comparative: '.$result->getComparative().PHP_EOL;

DataSet Example

By default if no dataset is passed to the constructor, it uses the AFINN dataset. You can create your own datasets or even modify a default dataset., (*3)

Here is how you can use another dataset., (*4)

use CertifiedWebNinja\Caroline\Analysis;
use CertifiedWebNinja\Caroline\DataSets\AFINN;

$afinn = new AFINN;

$caroline = new Analysis($afinn);

$result = $caroline->analyze('Hey you worthless scumbag');

echo 'Score: '.$result->getScore().PHP_EOL;
echo 'Comparative: '.$result->getComparative().PHP_EOL;

This will return the same results as the Simple Example above, what's neat about this though is by instantiating the AFINN dataset before the analysis class, you can replace and even extend the dataset as AFINN extends AbstractDataSet which gives a few helper methods on the dataset., (*5)

Replace dataset words

$afinn->replace(['love' => 5]);

$caroline = new Analysis($afinn);

$result = $caroline->analyze('I love my cat.');

echo $result->getScore(); // 5

Extend dataset

$afinn->extend(['cat' => 3]);

$caroline = new Analysis($afinn);

$result = $caroline->analyze('I love my cat.');

echo $result->getScore(); // 6 because "love" and "cat" both have a score of 3 each.

You can also create your own datasets to use by extending AbstractDataSet, (*6)

<?php namespace Acme;

use CertifiedWebNinja\Caroline\DataSets\AbstractDataSet;

class DataSet extends AbstractDataSet
{
    protected $dataSet = [
        'anvil' => -4,
        'catch' => 3
    ];
}

The Versions

19/09 2014

dev-develop

dev-develop

AFINN-based sentiment analysis

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

analysis sentiment certifiedwebninja afinn caroline

18/09 2014

dev-master

9999999-dev

AFINN-based sentiment analysis

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

analysis sentiment certifiedwebninja afinn caroline

18/09 2014

1.0.1

1.0.1.0

AFINN-based sentiment analysis

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

analysis sentiment certifiedwebninja afinn caroline

18/09 2014

1.0.0

1.0.0.0

AFINN-based sentiment analysis

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

analysis sentiment certifiedwebninja afinn caroline