Resolve a Text Name to A Freebase Topic rename
author:
contributor:
published:
updated:
source uri:
Freebase Apps Help Topic /freebase/apps/help_topic
Status:
Summary
Given a string (e.g., "San Francisco") that is supposed to be the name of a Freebase topic ([`/en...
Content
Given a string (e.g., "San Francisco") that is supposed to be the name of a Freebase topic ([`/en/san_francisco`](http://www.freebase.com/view/en/san_francisco)), you can resolve the name to that topic by using the [Search API](http://freebaseapps.com/docs/web_services/search) (also known as the "Relevance" API). As it is a Web service with an HTTP entry point, you can call it directly using [`acre.urlfetch`](http://freebaseapps.com/docs/acre_api/acre#member_urlfetch), but we recommend the [`acre.freebase.search`](http://freebaseapps.com/docs/acre_api/acre.freebase#member_search) utility function:
> var r = acre.freebase.search(
> "San Francisco",
> { "type" : "/location/citytown",
> "type_strict" : "any",
> "limit" : 3
> }
> );
> if (r.code == "/api/status/ok") {
> var entry = r.result[0];
> var topicID = entry.id;
> ...
> }
While you can resolve a text name to a Freebase topic this way, it's not accurate, because many topics share the same name. We recommend that you use the Freebase Suggest API, which allows your user to interactively pick a topic from a list of suggestions. The Freebase Suggest API renders many more identifying details beyond just the name for each suggestion so that your user can make the right choice. See [this recipe](/wiki/Use_Freebase_Suggest_to_Let_Users_Search_for_A_Topic_to_Fill_in_A_Form) for more details.
> var r = acre.freebase.search(
> "San Francisco",
> { "type" : "/location/citytown",
> "type_strict" : "any",
> "limit" : 3
> }
> );
> if (r.code == "/api/status/ok") {
> var entry = r.result[0];
> var topicID = entry.id;
> ...
> }
While you can resolve a text name to a Freebase topic this way, it's not accurate, because many topics share the same name. We recommend that you use the Freebase Suggest API, which allows your user to interactively pick a topic from a list of suggestions. The Freebase Suggest API renders many more identifying details beyond just the name for each suggestion so that your user can make the right choice. See [this recipe](/wiki/Use_Freebase_Suggest_to_Let_Users_Search_for_A_Topic_to_Fill_in_A_Form) for more details.
Recent Discussions about Resolve a Text Name to A Freebase Topic
There is no discussion about this document.
Start the Discussion »