forked from JWHennessey/phpInsight
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
32 lines (25 loc) · 751 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?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";
}