[Developers] Can a link's opposite direction name be retrievedwith less queries?
Jason Douglas
jason at metaweb.com
Mon Sep 24 18:23:19 UTC 2007
Very cool! Please be sure to create a new topic of type Freebase
Application for it so others can find it too. :-)
-jason
On Sep 22, 2007, at 5:09 AM, Jim Weaver wrote:
> Freebasers,
>
>
>
> Here’s a link to the beginnings of a Freebase Object Browser that I
> developed in JavaFX Script. I’d like to continue making
> improvements to it, but am very new to Freebase, so please provide
> suggestions. You’ll need JRE 1.5 or later to run this, as it uses
> Java Web Start to deploy.
>
>
>
> http://jmentor.com/JavaFX/JFXfreebaseBrowser.jnlp
>
>
>
> Thanks,
>
> Jim Weaver
>
> http://jmentor.com/about.php
>
> http://lat-inc.com
>
>
>
>
>
>
>
> From: developers-bounces at freebase.com [mailto:developers-
> bounces at freebase.com] On Behalf Of Jim Weaver
> Sent: Friday, September 21, 2007 3:31 PM
> To: Alec Flett
> Cc: developers at freebase.com
> Subject: Re: [Developers] Can a link's opposite direction name be
> retrievedwith less queries?
>
>
>
> Thanks Alec. I’ll post a link to the app on this list once I get
> it into a working state. I plan to improve it on it by showing
> images, etc. I’d like to also like to add the ability to navigate
> the higher-level freebase ontology to arrive at a topic. The
> information visualization piece of that should be fun.
>
>
>
> On a personal/professional note, the idea of applying structure to
> data on the internet has been a passion of mine for many years,
> mainly for the purpose of research and education. I’ve made
> several attempts at this, including using the Library of Congress
> Subject Headings as the ontology to reach information, with a
> desire to see it be able get to the granularity of primitive values
> (e.g. what is the population of New York). I am very excited that
> MetaWeb has done this by creating freebase, and congratulate you!
>
>
>
> Thanks,
>
> Jim Weaver
>
> http://jmentor.com/about.php
>
> http://lat-inc.com
>
>
>
>
>
> From: Alec Flett [mailto:alecf at metaweb.com]
> Sent: Friday, September 21, 2007 1:26 PM
> To: Jim Weaver
> Cc: developers at freebase.com
> Subject: Re: [Developers] Can a link's opposite direction name be
> retrieved with less queries?
>
>
>
> To answer the question in the subject: absolutely - in one query
> actually.
>
> First of all, you might be interested in the 'explore' view - its a
> debugging tool similar to what you've created here:
>
> http://www.freebase.com/view/explore/topic/en/the_police
>
> Look at the XmlHttpRequests that go by using Firebug - you'll learn
> quite a bit.
>
> (And a caveat - the code and the user interface are crude and
> unusual because this is really just for debugging..)
>
> On to the query:
>
> This query has the right idea - the problem is that it is saying
> "Give me all topics that have at least one master link, one reverse
> link, AND one value link" - i.e. the topic has to have all three...
> so you're going to miss topics that have only one of these.
>
> So for a given topic, you're going to need to put an "optional":
> true inside each of these /type/reflect/any_* clauses.
>
>
>
> "/type/reflect/any_reverse":[{
>
> "id":null,
>
> "link":null,
>
> "name":null,
>
> "type":[]
>
> }],
>
> "/type/reflect/any_value":[{
>
> "link":null,
>
> "type":null,
>
> "value":null
>
> }],
>
> "id":"/topic/en/the_police",
>
> "name":null
>
> }]
>
> }
>
>
>
>
>
> ...
>
> That works fine (e.g. “Musical Genres” in the screenshot), except
> when the link is an “any_reverse”. In this case, the link (and the
> name that comes back) is from the wrong perspective (like the
> “Recorded By” name in the screenshot). I know that I can do an
> additional query to get the link from the opposite perspective:
>
> You don't have to do an additional query but there is a bit of a
> trick here. Some properties that come back on any_reverse don't
> have a property name/id from the other direction (called a
> 'reciprocal property'). Depending on what you want your tool to do,
> you might only want the reverse values for properties that have a
> reverse back the other way. That's actually what the history view
> for a topic shows you.
>
> Here's the query clause to show all reverse links:
>
> "/type/reflect/any_reverse":[{
>
> "id":null,
>
> "link": {"master_property": {
> "id": null,
>
> "name": null,
> "reverse_property": {"id": null,
> "name": null,
> "optional": true }},
>
> "name":null,
>
> "type":[]
>
> }],
>
>
> Note that inside the master_property, I'm asking for the reverse -
> so you're essentially asking "On this reverse property, whats the
> reverse of that, coming the other way?"
>
> Notice that I added "optional" here - without optional, you'll only
> get values that have a reverse property coming in the other way.
> with optional, the "reverse_property" clause in the result may be
> null - in that case there isn't a property pointing back the other
> way.
>
> Also note that I added "name" so I'd get the english name of the
> property.
>
>
>
> My question is, can the number of queries to accomplish these
> results be reduced? By the way, when a link name (e.g. “Musical
> Genres” is returned, I’m caching that name so that I don’t have to
> query for it again.
>
>
>
> You can always expand these things even further and add things like
> expected_type, and/or by expanding the "type" field. The
> expected_type shows you the type that the property expects, while
> the 'type' clause actually asks for the list of types
>
> "/type/reflect/any_reverse":[{
>
> "id":null,
>
> "link": {"master_property": {
> "id": null,
>
> "name": null,
>
> "expected_type": {"id": null, "name": null},
> "reverse_property": {"id": null,
> "name": null,
> "optional": true }},
>
> "name":null,
>
> "type":[{"id": null, "name": null]
>
> }],
>
>
> Hope that helps.
>
> Alec
>
> _______________________________________________
> Developers mailing list
> Developers at freebase.com
> http://lists.freebase.com/mailman/listinfo/developers
More information about the Developers
mailing list