Query for all Nobel Peace Prize recipients in Freebase - freebase

I want to query all recipients of the Nobel Peace Prize and the date (year) from Freebase. I looked at the site, which shows me all winners, but if I do the query here, I do only get "null" results!
What I have so far:
[{
"id": "/m/05f3q",
"/award/award_category/winners": []
}]

If you look at the schema for the information that you're trying to query, you can see that what you are getting back is actually an Award Honor object which has a schema like this. It's got a bunch of different properties, but it doesn't have any meaningful name which is why it's coming back as null.
Try something more along the lines of the below (add additional properties as needed):
[{
"type": "/award/award_honor",
"award": {
"id": "/m/05f3q"
},
"award_winner": [{
"id": null,
"name": null
}],
"year": null
}]

[{
"id": "/en/nobel_prize_in_economics",
"/award/award_category/winners": [{
"/award/award_honor/award_winner": [],
"/award/award_honor/year": null,
"/award/award_honor/award": null,
"/award/award_honor/honored_for": []
}]
}]
I cannot do it in just one call, so I do the same for "/en/nobel_prize_in_physiology_or_medicine", "/en/nobel_prize_in_chemistry", "/en/nobel_peace_prize", "/en/nobel_prize_in_literature".

Related

Freebase - query media_common on book_edition to get /book/book?

a complete beginner with freebase here, trying to understand how to make a query to find a /book/book by /book_edition/media_common/cataloged_instance/isbn13.
I tried this query and got this error: Type /book/book_edition does not have property media_common:
[{
"type": "/book/book",
"editions": [{
"media_common": [{
"cataloged_instance": [{
"isbn13": "9780812519112" //example isbn13 from ender's game - https://www.freebase.com/m/04v8gr6
}]
}]
}],
"id": null
}]
EDIT: this is the query I used to get the deprecated ISBN field on book_edition
[{
"type": "/book/book",
"editions": [{
"ISBN": "0312932081"
}],
"id": null
}]
The property is actually /media_common/cataloged_instance/isbn13 which you can discover by exploring the schema. Because it's from a different type than the expected type of /book/book/editions (which is /book/book_edition you need to use the fully qualified name. Ditto for the author property I added to the query below.
[{
"type": "/book/book",
"editions": [{
"/media_common/cataloged_instance/isbn13": "9780812519112"
}],
"id": null,
"name": null,
"/book/written_work/author": null
}]
without using the shorthand notation that allows us to drop type prefixes on property names, this query would look like:
[{
"/book/book/editions": [{
"/media_common/cataloged_instance/isbn13": "9780812519112"
}],
"/type/object/id": null,
"/type/object/name": null,
"/book/written_work/author": null
}]
The expansion of the property names to their fully qualified versions gets done mechanically by the query processor without any real knowledge of the schema. Conversely, graph traversal treats the property names as opaque strings.

/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 must sort on a single value

I'm trying to learn to use Freebase, however when I try and do a sort by "/people/person/date_of_birth" for a search for actors for a show, it returns:
"code": 400,
"message": "Must sort on a single value, not at /tv/tv_program/regular_cast./tv/regular_tv_appearance/actor./people/person/date_of_birth"
Here is the full MQL query:
[{
"id": "/m/0524b41",
"name": [],
"sort":"/tv/tv_program/regular_cast./tv/regular_tv_appearance/actor./people/person/date_of_birth",
"/tv/tv_program/regular_cast": [{
"/tv/regular_tv_appearance/actor": [{
"name": [],
"/people/person/date_of_birth": []
}]
}]
}]
But you're not asking to sort on /people/person/date_of_birth, you're asking to sort on that long nested expression which goes through multiple intermediary nodes, some of which can appear multiple times (as indicated by the [] array notation). It's this multiplicity that MQL is complaining about.
To fix it, take your query, paste it into the query editor, click on the innermost /person/date_of_birth and then click "Invert Query." That will turn the query inside out and give you something that looks like this:
[{
"name": [],
"/people/person/date_of_birth": [],
"type": "/tv/tv_actor",
"!/tv/regular_tv_appearance/actor": [{
"!/tv/tv_program/regular_cast": [{
"id": "/m/0524b41",
"name": [],
"sort": "/tv/tv_program/regular_cast./tv/regular_tv_appearance/actor./people/person/date_of_birth"
}]
}]
}]
which isn't exactly what you want, but indicates the general shape of your target query.
Getting rid of the array brackets for single valued properties and moving the sort clause to the outside gives us:
[{
"name": null,
"/people/person/date_of_birth": null,
"sort": "/people/person/date_of_birth",
"type": "/tv/tv_actor",
"!/tv/regular_tv_appearance/actor": [{
"!/tv/tv_program/regular_cast": [{
"id": "/m/0524b41",
"name": null
}]
}]
}]
which is functional and returns our 81 regular Game of Thrones actors sorted by birth date, but could still be cleaned up a bit more. The !inverse property notation isn't necessary since we have forward equivalents and we don't really need to get the Game of Thrones info over and over again since it's constant and we really just want to use it as a filter.
Incorporating these final tweaks gives us a final query like this which returns nice compact results:
[{
"name": null,
"/people/person/date_of_birth": null,
"sort": "/people/person/date_of_birth",
"type": "/tv/tv_actor",
"starring_roles": [{
"series": {
"id": "/m/0524b41"
},
"limit": 0
}]
}]
The "limit": 0 clause is a little trick to cause MQL to use that subquery for filtering, but not bother returning any of the (constant) information in the results. The /tv/tv_actor/starring_roles and /tv/regular_tv_appearance/series can be abbreviated to the simple property names because their types are implied by their context.
Since there are only 81 results, MQL's default limit of 100 is plenty and we don't need to worry about increasing it or using cursors.
Oldest Game of Thrones actor: Peter Vaughn, born 1923.
Youngest: Lino Facioli b. 2000
Note that 7 actors don't have birth dates in Freebase, so we don't know where they rank age-wise. Here's a bonus query which returns their names and ids as well as their character's name. If we were running a production system, we might use something like this to feed a human curation queue to fill in the gaps.
[{
"name": null,
"/people/person/date_of_birth": {
"value": null,
"optional": "forbidden"
},
"type": "/tv/tv_actor",
"starring_roles": [{
"series": {
"id": "/m/0524b41"
},
"character":null
}]
}]
The seven character/actor pairs are (were): Roose Bolton - Michael McElhatton,
Gregor Clegane - Conan Stevens,
Hizdahr zo Loraq - Joel Fry,
Rickon Stark - Art Parkinson,
Janos Slynt - Dominic Carter,
Hodor - Kristian Nairn,
Tommen Baratheon - Callum Wharry. I say "were" because I couldn't resist fixing Hodor's birth date. The strange thing is that it was in Wikipedia, so should have been picked up automatically by Freebase. I think there's a bug lurking there somewhere.

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 beginner: getting an athlete's sport

I'm trying to use Freebase to find out what team a professional athlete belongs to.
So I'm trying to do something like this
[{
"id": null,
"name": "Kobe Bryant",
"type": "/sports/pro_athlete",
"sports_played": []
}]​
query editor
and then extract the property "sport_played" to find out what sport the player belongs to. My plan is to then do a more specific query for "basketball_player" or so until I finde the team name. (Is a simpler way to do this?)
However, I already fail at the first step, because in the results, while the properties sport_played and sport_played_professionally contain a single entry, that entry is null:
{
"code": "/api/status/ok",
"result": [{
"id": "/en/kobe_bryant",
"name": "Kobe Bryant",
"sports_played": [
null
],
"type": "/sports/pro_athlete"
}],
"status": "200 OK",
"transaction_id": "cache;cache03.p01.sjc1:8101;2012-06-13T13:30:20Z;0053"
}
I'm confused: I know from browsing the database that there should be a sport value for this player. And the result clearly shows that there is a single value in the "sports_played" list in the result.
But why is it null? Shouldn't is rather be a reference to a Basketball object?
Your query is asking for a list of sports_played but since you only used square braces it will only return a list of the names of all the matching topics.
If you add curly braces to the query you'll see that sports_played actually returns one topic with name = null (which is what your previous query was showing)
[{
"id": null,
"name": "Kobe Bryant",
"type": "/sports/pro_athlete",
"sports_played": [{}]
}]
This is because the expected value of sports_played is a CVT called Sports played which links athletes to sports for specific periods of time. This is so that we can keep track of athletes that have played multiple sports and know which one is the most current.
If you want to see the values inside the CVT object, you'll need to drill down further like this:
[{
"id": null,
"name": "Kobe Bryant",
"type": "/sports/pro_athlete",
"sports_played": [{
"type": "/sports/pro_sports_played",
"sport": {
"id": null,
"name": null
},
"career_start": null,
"career_end": null
}]
}]
Try it in the Query Editor
The sports_played property isn't really what you want here since it's not necessarily correlated with the properties which contain the team information.
Instead you want to use something along the lines of:
{
"id": null,
"name": "Kobe Bryant",
"/basketball/basketball_player/team" : [{"team":null}],
}]
}
if you wanted to get all the teams for all the Kobe Bryants you could use something like:
[{
"id": null,
"name": "Kobe Bryant",
"/soccer/football_player/current_team" : [{"team":null,"optional":true}],
"/basketball/basketball_player/team" : [{"team":null,"optional":true}],
"/american_football/football_player/current_team" :[{"team":null,"optional":true}]
}]
}]​
Unfortunately you'll need to go through the schema by hand and pull out the properties of interest by hand since they're not reliably regular enough to query automatically, but there really aren't that many sports to consider, so it shouldn't take very long to assemble your list.

Resources