Tags

, , ,

Yahoo provides a term extraction web service by which you can extract important keyphrases from a given text.The service is accessible via Yahoo Boss.You will need a Yahoo! BOSS Application ID to use it. It’s free of cost, so get it :)

Then you can use the PHP cURL  function to post the variables to the specified URL and return the result to a variable($xml here). The function I used if pasted below:

PHP Function:

function getKeyphrases($texttoprocess){
// cURL must be installed for this to work
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ‘http://api.search.yahoo.com/ContentAnalysisService/V1/termExtraction’);       curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, ‘appid=PASTE YOUR YAHOO BOSS APP ID HERE&context=’ . urlencode($texttoprocess) );
$xml = curl_exec($ch) or die(‘error’);
curl_close($ch);
return $xml
}

The sample working code with HTML GUI could be downloaded from here.(Don’t forget to add your App ID in yahoo.php file)