freebase - topic description/articles - freebase

I'm trying to retrieve the topic description for some film ("/film/film") and film genres ("film/film_genre") in italian language.
I think the problem is the same in both cases, so I post the MQL query that I'm trying to run for the film genre description:
Mql query
[{
"type": "/film/film_genre",
"name": "Film culto",
"/common/topic/article": [{
"id": null
}]
}]
Response
{
"result": [{
"type": "/film/film_genre",
"name": "Film culto",
"/common/topic/article": [{
"id": "/m/01q0d"
}]
}]
}
With the article ID received ("/m/01q0d"), I would use the "trans/wrap" service (http://api.freebase.com/api/trans/raw/m/01q0d). However, even though I use the query parameter "lang=it", the article is in English... :(
Any suggestions? I'm going crazy :D

Freebase contains non-English names, but it doesn't, for the most part, contain descriptions in anything other than English. You could use the Topic API and get the /common/topic/topic_equivalent_webpage for the Italian Wikipedia to fetch the article/description from there, but that's probably the closest you'll get.
https://www.googleapis.com/freebase/v1/topic/m/01q03
And, as Phil said, the api.freebase.com is going away in a matter of days, so you need to be using the new APIs.

Related

Freebase MQL, check if Subject is an Entity

I want to know if a subject is a freebase entity (a topic) or not
and i have to do this with several names (1258 names). It does not
matter of which type the topic is it just matters if something with
a special name exists in the freebase database as a topic (not a
relation). The name could also be an alias.
So this is how far it is (Thx to Tom Morris)
[{
"id": null,
"t:type": "/common/topic",
"type": [],
"name": "Bill Gates"
}]
So there is only the part with the alias left.
The alias is optional. So from the example "Bill Gates" could
be a name OR an alias. If the name exists in one or both i want
to get a result.
Any ideas?
Changing your query to
[{
"id": null,
"type": [],
"name": "Bill Gates"
}]
Will fix the initial error (because an object can, and usually does, have multiple topics) and you can then check to see if it has the type /common/topic.
More directly, you could use
[{
"id": null,
"t:type": "/common/topic",
"type": [],
"name": "Bill Gates"
}]
to only return the 60 topics which are in Freebase with that name.
Of course, they're everything from a dead guy to books to audio recordings to the person most people would associate with the name. Are these really all equivalent for your purposes?
Also, if you instead searched for "William Gates," you wouldn't find the most famous one, because that's an alias for him, not the primary name.e

/film/film/runtime always returns null

Whenever I try to query for the length of a film I get lists of null. The query I use is directly from the "Build query" button on their site and looks like this:
[{
"id": null,
"name": null,
"type": "/film/film",
"/film/film/runtime": []
}]
Ufortunately all the responses I get look like this:
{
"name": "4D Man",
"type": "/film/film",
"/film/film/runtime": [
null
],
"id": "/en/4d_man"
}
I can hover over the links you can see on the query page and see the runtime (in this case 85 minutes) but as you can see all I get from the query is null. This may be a Freebase bug, but any help is appreciated. Thank you.
There's not a single runtime of a film, the same film can have different runtimes (original version, director's cut, etc...) Freebase use the film_cut type to contain the different runtimes of a movie
You can use this query to get the runtimes:
[{
"id": null,
"name": null,
"/film/film/runtime": [{
"runtime": null
}]
}]
Tune this query to your needs, you may need type_of_film_cut or film_release_region.

Freebase MQL Query

I have a couple of questions.
I have a MQL query that gets some movie information. The trimmed query looks like this.
[{
"id": "/en/a_beautiful_mind",
"name": null,
"type": "/film/film",
"/common/topic/article": [{
"id": null,
"optional": true,
"limit": 3
}]
}]
it works just fine, I can retrieve the ID but is there a way to also get the article text without having to run a separate text query?
Second is I am trying to figure out how to get the featured song performer. I can do this and get the songs name.
[{
"id": "/en/a_beautiful_mind",
"name": null,
"type": "/film/film",
"featured_song": [{
"name": null,
"optional": true
}],
}]
But cant seem to figure out how to get the songs performer. Is it possible?
thanks for the help
Scott
One simple way to get this type of information about a film is to use the Topic API like this:
https://www.googleapis.com/freebase/v1/topic/en/a_beautiful_mind?filter=suggest&filter=/film/film
This won't get the featured song artist though. At least not without an additional API call. To do that in MQL you just nest additional queries inside the featured song like this:
[{
"id": "/en/a_beautiful_mind",
"name": null,
"type": "/film/film",
"featured_song": [{
"name": null,
"/music/recording/artist": [{}],
"/film/film_featured_song/performed_by": [{}],
"optional": true
}]
}]
Note that I've added two separate properties one for the artist who originally recorded the song and one for the artist who performed it in the film. In this case, the second property is empty implying that the original recording was used. Since I'm mixing properties from different types I need to use the fully-qualified property names.
All Freebase types are documented in the graph so you can look up types like /music/recording and /film/film_featured_song to see how they are meant to be used.

Freebase MQL query - Get data by a social link

I'm having a hard time trying to get data about a person from Freebase using his social link - by a MQL query.
How could this be done?
Something like:
https://www.googleapis.com/freebase/v1/mqlread?query={
"*":[{}],
"/common/topic/social_media_presence":[{
"value":"http://twitter.com/JustinBieber"
}]
}
Those links are really stored as keys and the links are generated from templates with they key plugged in. You can see all the keys here: https://www.freebase.com/m/06w2sn5?keys=
A modified version of your query would be:
[{
"key": [{
"namespace": {
"id": "/authority/twitter"
},
"value": "JustinBieber"
}],
"*": [{}]
}]
You can do the same thing with other namespaces like /authority/facebook or /authority/musicbrainz as well as the various language wikipedias e.g. /wikipedia/en
I'm not sure how complete the coverage or currency of the social media info is though...

Freebase MQL Query print article?

here's my query:
[{
"type": "/tv/tv_series_episode",
"series": "The Simpsons",
"guest_stars": [{
"actor": {
"/common/topic/article": [{
"id": null,
"optional": true,
"limit": 3
}],
"name": null
}
}]
}]
Freebase is returning an id for the article such as: id: "/m/0sw7x", how would I print this ID. I've read that you have to use a "trans" service but I'm not exactly sure how to do this...
The trans service is actually pretty simple to use. You just append that ID to the end of a GET request and it sends back the article content like this:
http://api.freebase.com/api/trans/raw/m/0sw7x
I gave a more detailed explanation to a similar question here.
Or you can fetch the article directly with MQL as detailed in my answer to the question narphorium's pointed at.

Resources