Beispiel #1
0
sentiment/feeling.</p>

<p>In order to produce this system, a Text Classification technique
has to be adapted to a given application domain. In this demo, the
<a href='http://nlp.cs.swarthmore.edu/semeval/'>SemEval-2007 dataset</a>
is of use for training the classifier, and the learnt model is then 
applied to processing similar world news headlines from 
The Washington Post:</p>

<?php 
// Prepare classifier
$classifier = new MultinomialNaiveBayes();
$classifier->setDatabase("semeval07");
// Prepare data
$feeder = new FeedRSS();
$aFeeds = $feeder->getFood("http://feeds.washingtonpost.com/rss/world");
foreach ($aFeeds as $feed) {
    $lab = $classifier->classify($feed["title"]);
    if ($lab == "NEG") {
        echo "<p class='neg'>";
    } elseif ($lab == "NEU") {
        echo "<p class='neu'>";
    } else {
        echo "<p class='pos'>";
    }
    echo "&#8226;&nbsp;&nbsp;" . $feed["title"] . " - <a href='" . $feed["link"] . "'>Read more</a></p>";
}
?>

<?php 
putFooter();