Beispiel #1
0
$contAcciones = 1;
// Aañado las 2 variables para quedarme con el coeficiente de sentimiento
$contadorParcial = 0;
$valorSentimientoParcial = 0.0;
//recorremos las acciones de las escenas y añadimos un nuevo atributo por cada una con el valor devuelto por el analizador
foreach ($pelicula->vis->timeSlice as $timeSlice) {
    //echo "Escena $contEscenas \n";
    foreach ($timeSlice->pointGroup->accion as $accion) {
        //echo "Acción $contAcciones \n". $accion->attributes()['descripcion'];
        $doc = $accion->attributes()['descripcion'];
        $sentences = explode(".", $doc);
        $score = array('pos' => 0, 'neg' => 0);
        foreach ($sentences as $sentence) {
            if (strlen(trim($sentence))) {
                $contadorParcial++;
                $class = $op->classify($sentence);
                //echo "Classifying: \"" . trim($sentence) . "\" as " . key($class) . "\n"; var_dump($class);
                $score[$class]++;
                $valorSentimientoParcial += $class['pos'] - $class['neg'];
                if (key($class) == 'pos') {
                    $valorSentimiento++;
                } else {
                    $valorSentimiento--;
                }
            }
            //      echo "</br>";
        }
        //var_dump($score);
        // se añade el sentimiento global de la accion
        $accion->addAttribute('valorSentimiento', $valorSentimientoParcial);
        $color = $util->hex_color_mod($colorPositivo, $valorSentimientoParcial);
Beispiel #2
0
<?php

include 'Opinion.php';
$op = new Opinion();
$op->addToIndex(__DIR__ . '/rt-polarity.neg', 'neg');
$op->addToIndex(__DIR__ . '/rt-polarity.pos', 'pos');
$text = "did we really act this way twenty years ago ? of course not";
$sentences = explode(".", $text);
$score = array('pos' => 0, 'neg' => 0);
foreach ($sentences as $sentence) {
    if (strlen(trim($sentence))) {
        $polarity = $op->classify($sentence);
        $score[$polarity]++;
    }
}
var_dump($score);
//$string = "This movie was noting else but a huge disappointment.";
//echo "Classifying '$string' - " . $op->classify($string) . "\n";
//$string = "Twilight was an atrocious movie, filled with stumbling, awful dialogue, and ridiculous story telling.";
//echo "Classifying '$string' - " . $op->classify($string) . "\n";
//$string = "Loving this wheater";
//echo "Classifying '$string' - " . $op->classify($string) . "\n";
Beispiel #3
0
<?php

require_once __DIR__ . '/Opinion.php';
$op = new Opinion();
$op->addToIndex(__DIR__ . '/opinion/rt-polaritydata/rt-polarity.neg', 'neg');
$op->addToIndex(__DIR__ . '/opinion/rt-polaritydata/rt-polarity.pos', 'pos');
$string = "Avatar had a surprisingly decent plot, and genuinely incredible special effects";
echo "Classifying '{$string}' - " . $op->classify($string) . "\n";
$string = "Twilight was an atrocious movie, filled with stumbling, awful dialogue, and ridiculous story telling.";
echo "Classifying '{$string}' - " . $op->classify($string) . "\n";
$string = "Loving this wheater";
echo "Classifying '{$string}' - " . $op->classify($string) . "\n";