Freebase 查询完整主题摘要

发布于 2024-10-15 23:39:34 字数 363 浏览 5 评论 0原文

我正在尝试检索一些 Freebase 文章的完整主题描述/摘要。我一直在使用 Freebase 主题 API,它返回这种类型的结果: http://www.freebase.com/experimental/topic/standard?id=/en/jimi_hendrix

但我注意到描述不完整并且以“...”结尾。有没有办法使用一些 Freebase API 来获取文章的完整描述?

Freebase 是否存储完整的描述,还是仅存储 Wikipedia 中的部分描述?

I'm trying to retrieve the full topic description/summary for some Freebase articles. I have been using the Freebase topic API, which returns this type of results: http://www.freebase.com/experimental/topic/standard?id=/en/jimi_hendrix

But I notice that the description is not complete and ends with "...". Is there a way to use some Freebase API to obtain the article's full description?

Does Freebase even store the complete description or does it just stores a portion of the description from Wikipedia?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

请叫√我孤独 2024-10-22 23:39:34

Freebase 仅存储维基百科描述的一部分,但通常比主题 API 给出的内容更多。

要获取与 Freebase 主题相关的 Wikipedia 简介的“完整”文本,您首先需要查询 阅读 API 以获取相关文章的列表,如下所示:

{
  "id": "/en/jimi_hendrix",
  "/common/topic/article": [{}]
}​

在查询编辑器中尝试

然后选择一个或多篇它返回的文章,并将其 ID 馈送到 /trans/raw API 像这样:

http://api.freebase.com/api/trans/raw/m/043dz

您会注意到返回的文本简介有点长(1200 个字符),并且没有“...”,但最后仍然被截断。

当我在网页中显示 Freebase 主题描述时,我有一些代码可以预先清理它。我通过查找换行符将其分成多个段落,然后如果最后一段不以句号、感叹号或问号结尾,我就会丢弃该段落。按照维基百科简介的编写方式,您通常只需要第一段。

Freebase just stores a portion of the Wikipedia description but there is usually more than what's given by the topic API.

To get the "full" text for a Wikipedia blurb associated with a Freebase topic you first need to query the Read API for a list of related articles like this:

{
  "id": "/en/jimi_hendrix",
  "/common/topic/article": [{}]
}​

Try it in the Query Editor

Then choose one or more of the articles that it returns and feed its ID into the /trans/raw API like this:

http://api.freebase.com/api/trans/raw/m/043dz

You'll notice that the blurb of text that gets returned is a bit longer (1200 chars) and doesn't have the "..." but its still chopped off at the end.

When I display Freebase topic descriptions in a web page I have some code to clean it up before hand. I split it apart into paragraphs by looking for newlines and then if the last paragraph doesn't end with a period, exclamation mark or question mark I just throw away that paragraph. The way the Wikipedia blurbs are written, you usually only need the first paragraph anyways.

俯瞰星空 2024-10-22 23:39:34

您还可以使用“text”扩展直接从 MQL 获取此信息:

{
"id": "/en/jimi_hendrix",
“/常见/主题/文章”:[{
“文本”: {
“最大长度”:16384,
“字符”:空
}
}]

注意,您需要打开 MQL 扩展才能使其工作 - 请参阅此处以获取相关示例行动。

2012 年 8 月编辑:虽然这适用于原始的 freebase.com 托管 API,但 MQL 扩展功能已从新的 googleapis.com 托管 API 中删除,因此不应再依赖此方法。

You can also fetch this directly from MQL with the "text" extension:

{
"id": "/en/jimi_hendrix",
"/common/topic/article": [{
"text": {
"maxlength": 16384,
"chars": null
}
}]
}​

Note that you'll need to turn on MQL extensions for this to work - see here for an example of this in action.

Edit August 2012: while this works for the original freebase.com hosted APIs, the MQL extension functionality has been removed from the new googleapis.com hosted APIs, so this method shouldn't be relied on any more.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文