ere
ere

Reputation: 1779

freebase getting plain names of types and sorting by commonality

I'd like to be able to get a list of types by their common name from a freebase ID

{
  "id":    "/m/02mjmr", #obama
  "type":[]
}​

How can I return the names of the types instead of their IDs? The above returns

0: "/common/topic"xp
1: "/people/person"xp
2: "/user/robert/default_domain/presidential_candidate"xp
3: "/book/author"xp
4: "/award/award_winner"xp
5: "/book/book_subject"xp
6: "/user/robert/x2008_presidential_election/candidate"xp
7: "/government/politician"xp
8: "/organization/organization_member"xp
9: "/user/robert/default_domain/my_favorite_things"xp

And lastly, how could I sort them by count? or by notability possibly?

Ie,

President
Nobel Prize Winner
Author
Person

etc?

Possibly something similar to the notable types API, but it looks like it's going away?

http://wiki.freebase.com/wiki/Notable_types_API

Upvotes: 4

Views: 1112

Answers (2)

Tom Morris
Tom Morris

Reputation: 10540

You can get names and instance counts with

{
  "id": "/m/02mjmr",
  "type": [{
    "name":          null,
    "id":null,
    "/type/type/domain":{"key":[{"namespace":"/","limit":0}],"id":null}
    "/freebase/type_profile/instance_count": null,
    "sort":"/freebase/type_profile/instance_count"
  }]
}​

One definition of "notable" is low frequency, so you could just invert your instance count sort to get notability. Limiting this to types in the Freebase "commons" would exclude noisy user types. One way to identify commons types is to look for /type/type/domain property values which are in the root namespace (ie a single path segment like /government)

For your example, the lowest frequency commons types are:

 43 /government/us_president     US President    /government 
 51 /people/appointer    Appointer   /people  
 73 /architecture/building_occupant  Building Occupant   /architecture 
204 /government/political_appointer  Political Appointer     /government
230 /book/poem_character     Poem character  /book  
254 /event/public_speaker    Public speaker  /event

You could refine the filtering further by blacklisting the types that you think are not notable for your application. There are currently 2134 commons types and a bunch of those are primitive data types or things for system usage, so it wouldn't take you long to go through and hand curate the entire list.

Upvotes: 3

Shawn Simister
Shawn Simister

Reputation: 4603

You might also be interested in looking at the Freebase Search API which returns one or more notable types with each result. You can search for a specific topic by MID like this:

https://www.googleapis.com/freebase/v1/search?query=/m/02mjmr&indent=true

Upvotes: 1

Related Questions