Exemplo n.º 1
0
function sentiment_graph()
{
    if (!sentiment_exists()) {
        return;
    }
    $sent_html = '<fieldset class="if_parameters">
            <legend>Average sentiment detected</legend>
            <div id="if_panel_linegraph_sentiments">';
    $sent_html .= '<script type="text/javascript">';
    $avgs = sentiment_avgs();
    $r = count($avgs);
    $sent_html .= "var sdata = new google.visualization.DataTable()\n        sdata.addColumn('string', 'Date');\n        sdata.addColumn('number', 'Positive');\n        sdata.addColumn('number', 'Negative');\n        sdata.addColumn('number', 'Positive subjective');\n        sdata.addColumn('number', 'Negative subjective');\n        sdata.addRows({$r});";
    $counter = 0;
    foreach ($avgs as $key => $sentiment) {
        $sent_html .= "sdata.setValue(" . $counter . ", 0, '" . $key . "');";
        if (isset($sentiment[0])) {
            $sent_html .= "sdata.setValue(" . $counter . ", 1, " . $sentiment[0] . ");";
        }
        if (isset($sentiment[1])) {
            $sent_html .= "sdata.setValue(" . $counter . ", 2, " . $sentiment[1] . ");";
        }
        if (isset($sentiment[2])) {
            $sent_html .= "sdata.setValue(" . $counter . ", 3, " . $sentiment[2] . ");";
        }
        if (isset($sentiment[3])) {
            $sent_html .= "sdata.setValue(" . $counter . ", 4, " . $sentiment[3] . ");";
        }
        $counter++;
    }
    $sent_html .= "var schart = new google.visualization.LineChart(document.getElementById('if_panel_linegraph_sentiments'));\n    schart.draw(sdata, {width:1000, height:360, colors:['lightblue','pink','#3366cc','#dc3912'], fontSize:9, hAxis:{slantedTextAngle:90, slantedText:true}, chartArea:{left:50,top:10,width:850,height:300}});";
    $sent_html .= '</script>';
    $sent_html .= '<div class="txt_desc"><br /></div></fieldset>';
    echo $sent_html;
}
Exemplo n.º 2
0
                    <?php 
if (isset($_GET['dataset']) && $_GET['dataset'] == "iranelection2013") {
    ?>
                        <hr/>

                        <h3>Bursty keywords</h3>
                        <div class="txt_desc">Insert a word to see a table with frequencies and burstiness scores per interval. (You can specify the interval under the 'Tweet Statistics and Activity Metrics' heading above.)</div>
                        <div class="txt_desc">Use: find out whether certain words are bursty.</div>
                        <div class="txt_link"> &raquo; <a href="" onclick="$('#whattodo').val('trending'+getInterval());sendUrl('mod.trending.php');return false;">launch</a></div>
                    <?php 
}
?>

                    <?php 
if (sentiment_exists()) {
    ?>
                    </div><h2> Sentiment analysis</h2>
                    <div class='if_export_block'>
                        <h3>Export all tweets from selection, with sentiments</h3>
                        <div class="txt_desc">Contains all tweets and information about them (user, date created, ...).</div>
                        <div class="txt_desc">Use: spend time with your data.</div>
                        <div class="txt_link"> &raquo;  <a href="" onclick="$('#whattodo').val('export_tweets_sentiment');sendUrl('mod.export_tweets_sentiment.php');return false;">export</a></div>
                        <?php 
    if ($show_url_export) {
        ?>
                            <div class="txt_link"> &raquo;  <a href="" onclick="$('#whattodo').val('export_tweets_sentiment&includeUrls=1');sendUrl('mod.export_tweets_sentiment.php');return false;">export with URLs</a> (much slower)</div>
                        <?php 
    }
    ?>
                        <hr />