开发者

Freebase query for full topic summary

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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜