我正在使用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 响应中返回的:
我认为我用来解析 JSON 响应的opencalais.php类的这些代码行中的问题(这些是第 71-76 行):
foreach ($object as $item) {
if (!empty($item->_typeGroup) && !empty($item->name)) {
$this->entities[$item->_typeGroup][] = trim($item->name);
}
}