PHP Assignment Help | PHP Homework Help | PHP Project Support

PHP hypertext Preprocessor helps the programmer to create dynamic content that interact with the database. It is a server side scripting language and requires a reasonable amount of understanding the concepts hence often requires PHP programming help by online experts.

We offer solutions for your Php homework and will guarantee that you receive a solution that satisfies you.

Below is a Php project, but if you just need a Php online tutor then we can do that for you as well.

PHP Twitter sentiment analysis

Problem:

The task is to setup an online Twitter Sentiment Analysis tool using Twitter Streaming API. There is no specific guidline. The tool should determine if a tweet is positive or negative. Preferably with a graph. With detailed notes explaining the step-by-step implementation of the process – very important for the oral presentation. Preferable language is php, but can use any only if php is not possible.

Solution

Twitter sentimental analyser

Approach:

  • The aim of the application is to fetch real time tweets for a particular hashtag and then analyse the sentiment and decide the polarity of the tweet.
  • Twitter API is used to fetch the real time tweets from the twitter. The sentiments are decided using the naïve bayes approach.
  • For checking the accuracy of the calculated sentiment , alchemy API is used, which uses machine learning for analysing the sentiment and has an accuracy of 83% on an average.

Running the Code:

  • Set the $tweetcount parameter in index.php to define the number of tweets to be fetched .
  • run index.php file in browser.

Third party API’s used:

  • twitter API: to fetch real time tweets from twitter.

https://dev.twitter.com/

  • alchemy api: to check the accuracy of calculated sentiment against machine learning response.

http://www.alchemyapi.com/

  • Highchart.js: for generating charts

http://www.highcharts.com/

Technologies used:

Languages: html, php, css, javascript

Algorithms: machine learning, naïve bayes classification

Problems faced:

  • First major problem faced was to decide which algorithm to use. Machine learning would have been the most accurate. But since we don’t have have data to make the algorithm learn and also for learning we need huge amount of data which is not available and it will take too much time to manually generate the time. So the next best algorithm that was feasible was naïve bayes classification.
  • Secondly, there is no way to precisely check the accuracy. The best machine learning sentimental classifier available on the internet(alchemy api) has an accuracy of 83% only.

Python is interactive and object oriented high level programming language. It was created on year 1994 by Rasmus Lerdorf.  PHP is zipping in execution. Students across globe who wants easy help with python homework can come to us for it. Its syntax is similar to C-Like.

PHP is server side programming which is embedded in HTML hence requires good understanding of both. It also requires technique to manage database, dynamic content, session tracking. All the e-commerce websites built today are on PHP. This is easy to maintain. We have good experience in providing easy help with Programming language.

index.php

<!DOCTYPE html>
<html>
<head>

<meta http-equiv=”Cache-Control” content=”no-cache”>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>
<meta http-equiv=”Lang” content=”en”>
<script src=”jquery.min.js”></script>
<script src=”highcharts.js”></script>

<title>Twitter Sentiment Analysis Demo</title>
</head>
<body>
<h1>Twitter Sentiment Analysis</h1>
<p>Type your keyword below to perform Sentiment Analysis on Twitter Results:</p>
<form method=”GET”>
<label>Keyword: </label> <input type=”text” name=”q” />
<input type=”submit” />
</form>

<?php

if(isset($_GET[‘q’]) && $_GET[‘q’]!=) {
$tweetcount=’10’;
include_once(dirname(__FILE__).‘/config.php’);
include_once(dirname(__FILE__).‘/lib/TwitterSentimentAnalysis.php’);

$TwitterSentimentAnalysis = new TwitterSentimentAnalysis(DATUMBOX_API_KEY,TWITTER_CONSUMER_KEY,TWITTER_CONSUMER_SECRET,TWITTER_ACCESS_KEY,TWITTER_ACCESS_SECRET);
$count=0;
$count1=0;
$positive1=0;
$positive2=0;
$negative1=0;
$negative2=0;
$neutral1=0;
$neutral2=0;
//Search Tweets parameters as described at https://dev.twitter.com/docs/api/1.1/get/search/tweets
$twitterSearchParams=array(
‘q’=>$_GET[‘q’],
‘lang’=>‘en’,
‘count’=>$tweetcount,
);
$results=$TwitterSentimentAnalysis->sentimentAnalysis($twitterSearchParams);

?>
<h1>Results for “<?php echo $_GET[‘q’]; ?>“</h1>
<table border=”1″>
<tr>
<td>Id</td>
<td>User</td>
<td>Text</td>
<td>Twitter Link</td>
<!– <td>Expected Sentiment_datum</td>–>
<td>Expected Sentiment_alchemy</td>
<td>Calculated sentiment</td>
</tr>
<?php
foreach($results as $tweet) {

$color=‘#FF0000’;
$count1=$count1+1;

if($tweet[‘sentiment’]==‘positive’){
$positive1=$positive1+1;
}

if($tweet[‘sentiment’]==‘negative’){
$negative1=$negative1+1;
}

if($tweet[‘sentiment’]==‘neutral’){
$neutral1=$neutral1+1;
}

if($tweet[‘calculated’]==‘pos’){
$positive2=$positive2+1;
}

if($tweet[‘calculated’]==‘neg’){
$negative2=$negative2+1;
}
if($tweet[‘calculated’]==‘neu’){
$neutral2=$neutral2+1;
}

if($tweet[‘sentiment’]==‘neutral’ && $tweet[‘calculated’]==‘neu’){
$count=$count+1;
$color=‘#00FF00’;
}
if($tweet[‘sentiment’]==‘negative’ && $tweet[‘calculated’]==‘neg’){
$count=$count+1;
$color=‘#00FF00’;
}
if($tweet[‘sentiment’]==‘positive’ && $tweet[‘calculated’]==‘pos’){
$count=$count+1;
$color=‘#00FF00’;
}
?>
<tr style=”background:<?php echo $color; ?>;”>
<td><?php echo $tweet[‘id’]; ?></td>
<td><?php echo $tweet[‘user’]; ?></td>
<td><?php echo $tweet[‘text’]; ?></td>
<td><a href=”<?php echo $tweet[‘url’]; ?>” target=”_blank”>View</a></td>
<!–<td><?php //echo $tweet[‘sentimentd’]; ?></td>–>
<td><?php echo $tweet[‘sentiment’]; ?></td>
<td><?php echo $tweet[‘calculated’]; ?></td>
</tr>
<?php
}
?>
</table>
<p>Total number of tweets: <?php echo $count1; ?></p>
<p>Number of sentiments correctly calculated: <?php echo $count; ?></p>
<p>Accuracy: <?php echo $count*100/$count1;?>%</p>

<script>
var a=<?php echo $positive1; ?>;
var b=<?php echo $positive2; ?>;
var n=<?php echo $neutral1; ?>;
var m=<?php echo $neutral2; ?>;
var c=<?php echo $negative1; ?>;
var d=<?php echo $negative2; ?>;
</script>
<?php
}

?>
<div id=”container” style=”min-width: 310px; height: 400px; margin: 0 auto”></div>
<script type=”text/javascript”>
$(function () {
$(‘#container’).highcharts({
chart: {
type: ‘column’
},
title: {
text: ‘twitter sentimental analizer’
},
subtitle: {
text: ‘result’
},
xAxis: {
categories: [
‘Expected’,
‘calculated’
]
},
yAxis: {
min: 0,
title: {
text: ‘tweets’
}
},
tooltip: {
headerFormat: ‘<span style=”font-size:10px”>{point.key}</span><table>’,
pointFormat: ‘<tr><td style=”color:{series.color};padding:0″>{series.name}: </td>’ +
‘<td style=”padding:0″><b>{point.y:.1f} mm</b></td></tr>’,
footerFormat: ‘</table>’,
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [{
name: ‘positive’,
data: [a, b]

},{
name: ‘neutral’,
data: [n, m]

},{
name: ‘negative’,
data:


[c, d]

}]
});
});
</script>
</body>
</html>

PHP supports major protocols like POP3, IMAP etc hence is the most popular programming language. You can enjoy programming it but if your concept are not clear and requires good guidance you can reach out to our PHP programming experts. You can email your assignment or can upload it easily your assignment.

Your requirement on help with php programming is always taken on priority by our online PHP experts. They provide you well documented explanation for your projects and well commented codes so that you can easily understand it. We have pool of PHP experts who are ready to help you anytime or from anyplace.

Our PHP expert tests your PHP programming assignment codes and then delivers it to you on time. Five important characteristics of PHP which our experts always need to keep in mind are- Simplicity, efficiently, Security, Flexibility and Familiarity. This makes our PHP language very robust and very important.

TwitterSentimentAnalysis.php

<?php
include_once(dirname(__FILE__).'/DatumboxAPI.php');
include_once(dirname(__FILE__).'/twitter-client.php');
include_once('alchemyapi.php');
require_once __DIR__ . '/../autoload.php';
class TwitterSentimentAnalysis {

    protected $datumbox_api_key; //Your Datumbox API Key. Get it from http://www.datumbox.com/apikeys/view/

    protected $consumer_key; //Your Twitter Consumer Key. Get it from https://dev.twitter.com/apps
    protected $consumer_secret; //Your Twitter Consumer Secret. Get it from https://dev.twitter.com/apps
    protected $access_key; //Your Twitter Access Key. Get it from https://dev.twitter.com/apps
    protected $access_secret; //Your Twitter Access Secret. Get it from https://dev.twitter.com/apps

    /**
    * The constructor of the class
    * 
    * @param string $datumbox_api_key   Your Datumbox API Key
    * @param string $consumer_key       Your Twitter Consumer Key
    * @param string $consumer_secret    Your Twitter Consumer Secret
    * @param string $access_key         Your Twitter Access Key
    * @param string $access_secret      Your Twitter Access Secret
    * 
    * @return TwitterSentimentAnalysis  
    */
    public function __construct($datumbox_api_key, $consumer_key, $consumer_secret, $access_key, $access_secret){
        $this->datumbox_api_key=$datumbox_api_key;

        $this->consumer_key=$consumer_key;
        $this->consumer_secret=$consumer_secret;
        $this->access_key=$access_key;
        $this->access_secret=$access_secret;
    }

    /**
    * This function fetches the twitter list and evaluates their sentiment
    * 
    * @param array $twitterSearchParams The Twitter Search Parameters that are passed to Twitter API. Read more here https://dev.twitter.com/docs/api/1.1/get/search/tweets
    * 
    * @return array
    */
    public function sentimentAnalysis($twitterSearchParams) {
        $tweets=$this->getTweets($twitterSearchParams);

        return $this->findSentiment($tweets);
    }

    /**
    * Calls the Search/tweets method of the Twitter API for particular Twitter Search Parameters and returns the list of tweets that match the search criteria.
    * 
    * @param mixed $twitterSearchParams The Twitter Search Parameters that are passed to Twitter API. Read more here https://dev.twitter.com/docs/api/1.1/get/search/tweets
    * 
    * @return array $tweets
    */
    protected function getTweets($twitterSearchParams) {
        $Client = new TwitterApiClient(); //Use the TwitterAPIClient
        $Client->set_oauth ($this->consumer_key, $this->consumer_secret, $this->access_key, $this->access_secret);

        $tweets = $Client->call('search/tweets', $twitterSearchParams, 'GET' ); //call the service and get the list of tweets

        unset($Client);

        return $tweets;
    }

    protected function findSentiment($tweets) {
        //$DatumboxAPI = new DatumboxAPI($this->datumbox_api_key); //initialize the DatumboxAPI client
        $analyse=new alchemyAPI();
        $Calculatedsentiment = new \PHPInsight\Sentiment();
        $results=array();
        foreach($tweets['statuses'] as $tweet) { //foreach of the tweets that we received
            if(isset($tweet['metadata']['iso_language_code']) && $tweet['metadata']['iso_language_code']=='en') { //perform sentiment analysis only for the English Tweets
                $sentimentd='neutral';//$DatumboxAPI->TwitterSentimentAnalysis($tweet['text']); //call Datumbox service to get the sentiment
                $response=$analyse->sentiment('text',$tweet['text'],null);
                $scores = $Calculatedsentiment->score($tweet['text']);
                $class = $Calculatedsentiment->categorise($tweet['text']);
                if($response['status'] == 'OK'/*&&$response['docSentiment']['type']!='neutral'*/) { //if the sentiment is not false, the API call was successful.
                    $results[]=array( //add the tweet message in the results
                        'id'=>$tweet['id_str'],
                        'user'=>$tweet['user']['name'],
                        'text'=>$tweet['text'],
                        'url'=>'https://twitter.com/'.$tweet['user']['name'].'/status/'.$tweet['id_str'],

                        'sentiment'=>$response['docSentiment']['type'],//$sentiment[],
                        'sentimentd'=>$sentimentd,
                        'calculated'=>$class
                    );
                }
            }

        }

        unset($tweets);
        //unset($DatumboxAPI);
        unset($analyse);
        unset($Calculatedsentiment);

        return $results;
    }
}

A most important and simple tag for PHP is <?PHP?>. Every tags are based on it. In order program or test what our PHP programmer has tested or coded, you need to have your PHP environment setup done on your machine. This will help us to ensure full confidence before you submit it in your university.

Our student friendly coordinator is available any time for your help. You can reach them easily and get good help with PHP programming assignment. They are here to establish engagement between you and the online PHP expert with us. You can happily relax once the payment is done. It is our commitment to delivery bug free PHP programming assignment solution to you before deadline.

If you are looking for help with PHP homework, then we can provide you with the solution, that is guaranteed plagiarism free.

Students from across globe come to us with all their queries to get instant help with PHP programming assignment. PHP can access structure information sent from a program, construct custom web substance to serve the program.

The biggest advantage of PHP programming is that is open source. Due to less system resource; PHP is very fast and hence is easy to use.