Is there a way using MQL to list all the types belong to a Freebase domain and to list all properties belonging to a type e.g. Given the domain "Computer" I would like to list all "types belonging to it as shown in:
http://www.freebase.com/computer?data=
The following query returns Types and the Domains they belong. The result has pairs of Type - Domain. There is also a filter to keep only the domains in the /category/commons (see List all Freebase Domains with MQL query or API call).
[{
"id": null,
"type": "/type/type",
"name": null,
"domain": {
"id": null,
"name": null
},
"ns0:domain": {
"!/freebase/domain_category/domains": {
"id": "/category/commons"
}
}
}]
Related
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.
I'd like to pull information (MID and US English name) about all locations in Freebase AND also their Korean names and any Korean aliases via an MQL query. This is as far as I've gotten:
[{
"id": null,
"name": null,
"mid": null,
"type": "/location/location",
"Korean:name": [{
"lang": "/lang/ko",
"value": null
}]
}]
I'm only getting the Korean name, but not any Korean aliases. I don't know how to write a query that outputs properties of 2 different types in the same query. Can you get data about both /location/location AND common/topic/alias for the same entity in the same MQL query/output? Is my approach just wrong here?
Any help appreciated.
When you need to combine properties from many different types you need to use the fully qualified property ID like this:
[{
"id": null,
"name": null,
"mid": null,
"type": "/location/location",
"Korean:name": [{
"lang": "/lang/ko",
"value": null
}],
"/common/topic/alias": [{
"lang": "/lang/ko",
"value": null,
"optional": true
}]
}]
Whenever you use shortened property IDs they are assumed to be in the same type as the type you specify in your query (or /type/object if no type is given). So for example, if you were to use "geolocation" in your query it would be interpreted as "/location/location/geolocation". The only excepts are "id", "name" and "type" which you can use without using the full IDs eg. "/type/object/name".
You'll also note that I made aliases "optional" so that it would return results for locations that don't have any aliases.
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.
I want to find out how Wenjin SU and Jimei University are related in Freebase. I have found out the Wenjin SU has a type /business/board_member/which has property/business/board_member/leader_of. How can I use this information in an Freebase MQL to extract the term or mid of Jimei University?
If you go to the Freebase page for Wenjin SU you see that he has the type /business/board_member/ and under that section it lists him as the /business/board_member/leader_of Jimei University
The first thing you should do is go to the Query Editor and create a skeleton MQL query for that relationship:
{
"id": "/m/0sxhm9v",
"name": null,
"/business/board_member/leader_of": [{}]
}
When you run this query you get the following result:
{
"result": {
"name": "Wenjin SU",
"/business/board_member/leader_of": [{
"name": null,
"type": [
"/organization/leadership"
],
"id": "/m/0sxhm9s"
}],
"id": "/m/0sxhm9v"
}
}
This is not quite what you were asking for. It's saying that he is the leader_of an un-named topic /m/0sxhm9s. Now, if you visit the Freebase page for that topic you'll see that its a mediator node that connects a person and their role to an organization for a specific date range. You'll also notice that Jimei University is listed as the /organization/leadership/organization on this page.
We can now add this mediated property to our MQL query to get the full relationship that you're looking for:
{
"id": "/m/0sxhm9v",
"name": null,
"/business/board_member/leader_of": [{
"/organization/leadership/organization": {
}
}]
}
If you're building an application that has a pre-determined set of relationships like this then you can use this process of exploring the Freebase data to build MQL queries for those relationships. If you're looking to find any arbitrary connection between any two entities in Freebase then you'll need to download the Freebase Data Dumps and run a shortest path algorithm over the entire graph.
I would like to develop a Freebase java application that lets you browse Freebase.
I thought a good starting point would be to mimic the Freebase Schema Explorer and allow the user of my app to "drill down" through Domains, Types in a Domain, then Instances in a Type.
Can someone please assist in how you retrieve a List of domains?
Then a list in that domain? etc...
The user can then select a domain and i would like to preset a list of types within that domain and so on until they have found the entry or entries they are investigating.
MQL for domains:
[{
"id": null,
"name": null,
"type": "/type/domain",
"!/freebase/domain_category/domains": {
"id": "/category/commons"
}
}]
The "!/freebase/domain_category/domains" clause in there is to restrict things to just the Commons (official) domains - otherwise you get the domain which is automatically created for every user and probably isn't what you're after.
Types in a domain:
[{
"id": null,
"name": null,
"type": "/type/type",
"domain": "/cvg"
}]
Replace "/cvg" as appropriate.
Instances of a type:
[{
"id": null,
"name": null,
"type": "/cvg/computer_videogame"
}]
Replace "/cvg/computer_videogame" as appropriate.
This should at least get you started.