我正在使用PHP-OpenCalais库从文本片段中提取数据。实体的var_dump给出如下内容:
Array
(
[IndustryTerm] => Array
(
[0] => Internet
[1] => software maker
[2] => Internet search
)
[Person] => Array
(
[0] => Steve Ballmer
[1] => Jerry Yang
[2] => Colin Gillis
)
[Company] => Array
(
[0] => Google Inc.
[1] => Canaccord Adams
[2] => Yahoo!
[3] => Microsoft Corp.
)
[Currency] => Array
(
[0] => USD
)
[SocialTag] => Array
(
[0] => New encyclopedism
[1] => Microsoft
[2] => Jerry Yang
[3] => Steve Ballmer
[4] => Bing
[5] => Yahoo!
[6] => Internet search engines
[7] => Hypertext
)
)
但是,这缺少了很多信息,例如,socialTag元素没有重要值,因为它在JSON响应中返回:
我认为来自opencalais.php类的这些代码行中的问题我用来解析JSON响应(这些是第71-76行):
foreach ($object as $item) {
if (!empty($item->_typeGroup) && !empty($item->name)) {
$this->entities[$item->_typeGroup][] = trim($item->name);
}
}