2012-05-17 15 views
8

文字列から気分を抽出できるAPIはありますか(PHPで使用しますが、任意の言語で実装できます)。つぶやきやメッセージの気分を検出する

もし存在しなければ、機械学習に関する何か、おそらく既知の肯定/否定の単語を抽出する分類子を構築するにはどうすればいいですか?

+3

これは役に立ちますか?http://stackoverflow.com/a/959162/995958 –

+3

これらのアップヴォートは、私が何かを見ているか、本当にこれを望んでいますが、これについて何か研究しましたか? (あなたの質問の第2部分のために)あなたの質問を下ろすことについてのヒントは、「この質問は研究努力を示していない」と始まることを覚えておいてください) – Nanne

+0

@Nanneは自分自身のために話しています;これが実現するのが面白いでしょう。 –

答えて

2

AlchemyAPIをお勧めします。彼らは、あなたの特定のケースのために。使用することは困難ではないはずである(非常にシンプルなAPIを持ってAlchemyapI上記の提案を使用してhere

+0

このapiの提案に従って、私がこれを行った方法は以下を参照してください –

0

に見て、ここではFacebookのステータス

$id = CURRENT USER ID; 
    $message = array(); //the users posts with scores 
    $status = $fb->fql("SELECT status_id, message FROM status WHERE uid=$id LIMIT 10"); 
    foreach($status as $stat) { 
    $message = file_get_contents("http://access.alchemyapi.com/calls/text/TextGetTextSentiment" 
         ."?outputMode=json&apikey=MYAPIKEY" 
         ."&text=".urlencode($stat['message'])); 
    $data = json_decode($message); //get reply 
    $messages[] = array("status"=>$stat['message'], "score"=>($data->docSentiment->type!="neutral") ? $data->docSentiment->score : 0); //save reply 
    } 

    $user = $fb->api("/".$id); //query the user 

    $content .= "<h3>".$user['name']."</h3>"; 

    $total = 0; 
    $count = 0; 
    foreach($messages as $message) { 
    $total += $message['score']; 
    if($message['score']!=0) $count++; 
    } 

    $content .= 'Has an average rating of '.$total/$count.' <meter min="-1" max="1" value="'.$total/$count.'"></meter><br /><br />'; 

    foreach($messages as $message) { 
    $content .= '<b>'.$message['status'].'</b> '.$message['score'].'</br>' 
       .'<meter ' //class="'.($message['score'] == 0 ? "yellow" : $message['score'] < 0 ? "red" : "green").'" ' 
       .'value="'.$message['score'].'" min="-0.5" max="0.5" optimum="0">'.$message['score'].' out of -1 to 1</meter><br /><br />'; 
    } 
に基づいて、本当にシンプルなシステムです
+0

これは、-1と+1の間の基本的な分析を提供します。 –

関連する問題