PHP Classes

File: inc/examples/demo.php

Recommend this page to a friend!
  Classes of Zacchaeus Bolaji   WordPress Plugin Sentiment Analysis   inc/examples/demo.php   Download  
File: inc/examples/demo.php
Role: Example script
Content type: text/plain
Description: Example script
Class: WordPress Plugin Sentiment Analysis
Analyze author sentiments in WordPress posts
Author: By
Last change:
Date: 1 year ago
Size: 754 bytes
 

Contents

Class file image Download
<?php
if (PHP_SAPI != 'cli') {
    echo
"<pre>";
}

$strings = array(
   
1 => 'Weather today is rubbish',
   
2 => 'This cake looks amazing',
   
3 => 'His skills are mediocre',
   
4 => 'He is very talented',
   
5 => 'She is seemingly very agressive',
   
6 => 'Marie was enthusiastic about the upcoming trip. Her brother was also passionate about her leaving - he would finally have the house for himself.',
   
7 => 'To be or not to be?',
);




require_once
__DIR__ . '/../autoload.php';
$sentiment = new \PHPInsight\Sentiment();
foreach (
$strings as $string) {

   
// calculations:
   
$scores = $sentiment->score($string);
   
$class = $sentiment->categorise($string);

   
// output:
   
echo "String: $string\n";
    echo
"Dominant: $class, scores: ";
   
print_r($scores);
    echo
"\n";
}