PHP& uClassify奇怪的bug

时间:2012-03-12 14:58:18

标签: php

  

可能重复:
  PHP & uClassify strange bug

我有一个PHP脚本,其代码如下

require_once("uClassify.php");

$name = $_POST['name'];

$uclassify = new uClassify();

// Set these values here
$uclassify->setReadApiKey('my-read-key');
$uclassify->setWriteApiKey('my-write-key');

$text=str_replace(" ", "+", $name);

$google_url = "http://uclassify.com/browse/uClassify/Sentiment/ClassifyText?readkey=My-Read-Key&text=".$text."&version=1.01";

$result = file_get_contents($google_url);

$resp = $uclassify->classify('Understanding if a text is positive or negative is easy for humans, but a lot harder for computers. We can “read between the lines”, get jokes and identify irony. Computers aren’t quite there yet but the gap is quickly closing in.', 'Sentiment', 'uClassify');


print_r($resp);

当我使用控制台运行它时,我得到下面的响应

Array
(
    [0] => Array
        (
            [id] => Classify2414835871331563718
            [classification] => Array
                (
                    [0] => Array
                        (
                            [class] => negative
                            [p] => 0.0650294
                        )

                    [1] => Array
                        (
                            [class] => positive
                            [p] => 0.934971
                        )

                )

            [text] => Understanding if a text is positive or negative is easy for humans, but a lot harder for computers. We can “read between the lines”, get jokes and identify irony. Computers aren’t quite there yet but the gap is quickly closing in.
        )

)

确定到目前为止,但是当我尝试在我的页面中使用表单i并在同一页面中获得答案时,没有任何内容出现。如果我评论该行

$resp = $uclassify->classify('Understanding if a text is positive or negative is easy for humans, but a lot harder for computers. We can “read between the lines”, get jokes and identify irony. Computers aren’t quite there yet but the gap is quickly closing in.', 'Sentiment', 'uClassify');

并回声一下,一切都恢复正常。

0 个答案:

没有答案
相关问题