Your SlideShare is downloading. ×
0
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Freebase Workshop, December 2009
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Freebase Workshop, December 2009

3,001

Published on

Presented at the Freebase NYC Workshop, December 2009. Covers basic MQL query construction, basic service calls and eMQL adapter construction. PHP Code can be found at …

Presented at the Freebase NYC Workshop, December 2009. Covers basic MQL query construction, basic service calls and eMQL adapter construction. PHP Code can be found at http://dev.mqlx.com/~jamie/nyc2009

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,001
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
38
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Freebase Workshop Jamie Taylor New York City, December 2009 Code available at: http://dev.mqlx.com/~jamie/nyc2009
  • 2. Building a MQL Query
  • 3. "type":"/type/object" is assumed "name" = /type/object/name [{ "name" : null, "type" : "/tv/tv_program" }] MQL
  • 4. http://www.freebase.com/app/queryeditor
  • 5. { "id":"/en/ncis", "name" : null, "type" : "/tv/tv_program" } MQL
  • 6. "/program_creator" = /tv/tv_program/program_creator { "id":"/en/ncis", "name" : null, "type" : "/tv/tv_program", "program_creator":[ ] } MQL
  • 7. { "id":"/en/ncis", "name" : null, "type" : "/tv/tv_program", "program_creator":[{ "id":null, "name":null }] } MQL
  • 8. Mark Harmon TV Performance Jethro Gibbs { "id":"/en/ncis", "name" : null, "type" : "/tv/tv_program", "program_creator":[{ "id":null, "name:null }], "regular_cast":[{ "actor":null, "character":null }] }
  • 9. { "id":"/en/ncis", "name" : null, "type" : "/tv/tv_program", "program_creator":[{ "id":null, "name:null }], "regular_cast":[{ "actor":null, "character":null }] }
  • 10. Mark Harmon TV Performance Jethro Gibbs { "id":"/en/ncis", "name" : null, "type" : "/tv/tv_program", "program_creator":[{ "id":null, "name:null }], "regular_cast":[{ "actor": {"id":null, "name":null}, "character":null }] }
  • 11. { "id":"/en/ncis", "name" : null, "type" : "/tv/tv_program", "program_creator":[{ "id":null, "name:null }], "regular_cast":[{ "actor": {"id":null, "name":null}, "character":null }], "spin_offs":[ ] }
  • 12. { "id":"/en/ncis", "name" : null, "type" : "/tv/tv_program", "program_creator":[{ "id":null, "name:null }], "regular_cast":[{ "actor": {"id":null, "name":null}, "character":null }], "spin_offs":[{"id":null, "name":null, "air_date_of_first_episode":null}] }
  • 13. Accessing Freebase Services via PHP
  • 14. Service Requests in PHP • Using cURL to make external service requests $topicid = "/en/ncis"; $widgeturl = "http://www.freebase.com/widget/topic?id= $topicid&mode=i&panes=image,article_props"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $widgeturl); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $resultstr = curl_exec($ch); curl_close($ch); print $resultstr;
  • 15. Accessing External Services via MQL Extensions
  • 16. A Graph of Entities
  • 17. A Graph of Services
  • 18. http://www.bestbuy.com/site/She+Wolf… http://www.daylife.com/topic/Shakira http://twitter.com/shakira http://www.facebook.com/shakira http://www.myspace.com/shakira http://www.last.fm/music/Shakira http://www.netflix.com/RoleDisplay/Shakira/20046629 http://www.guardian.co.uk/music/shakira
  • 19. eMQL: MQL Extensions • Request data from other service providers • Services accessed transparently within MQL query • Use Freebase Keys/Properties in external service request • Uses: • real-time data services • Stock quotes, sensor data • premium services • requests can specify private "api keys" for the service • fine grained & authoritative data sources
  • 20. eMQL Query {   "id":   "/en/ibm", ticker   "type": "/business/company",   "ticker_symbol": [{ "ibm"     "stock_exchange": null,     "ticker_symbol":null   }] }
  • 21. eMQL Query {   "id":   "/en/ibm",   "type": "/business/company", ticker   "ticker_symbol": [{     "stock_exchange": null, "ibm"     "ticker_symbol":null, "quote":null   }] }
  • 22. eMQL Query {   "id":   "/en/ibm",   "type": "/business/company", ticker   "ticker_symbol": [{     "stock_exchange": null, "ibm"     "ticker_symbol":null, "quote":null "pre"   }] } "fetch"
  • 23. eMQL Service Request • Pre • Modify MQL query to provide additional information necessary to complete request • e.g., retrieve specific namespace keys • Fetch • Produce (retrieve, calculate, format) value for the eMQL property • Reduce (optional) • Create a result that looks across all results returned in the query • Help • Document how the property is used
  • 24. MQL Read Service http://api.freebase.com/api/service/mqlread?query= {"query":{"id":"/en/ncis", "name":null}} http://api.freebase.com/api/service/mqlread?queries= {"q0":{"query":{"id":"/en/ncis", "name":null}}} {"q1":{"query":{"id":"/en/blade_runner", "name":null}}}
  • 25. MQL Requests in PHP {"id":"/en/ncis", "name":null} $topicid = "/en/ncis"; $simplequery = array('id'=>$topicid, 'name'=>null); $queryarray = array('q1'=>array('query'=>$simplequery)); #query envelope $jsonquerystr = json_encode($queryarray); $mqlurl = "http://www.freebase.com/api/service/mqlread?queries=". $jsonquerystr; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $mqlurl); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $resultstr = curl_exec($ch); curl_close($ch); $resultarray = json_decode($resultstr, true); #true:give us an array $topicname = $resultarray["q1"]["result"]["name"]
  • 26. Demo eMQL Extensions stock quote @tag references
  • 27. TV Episode Adapter Query: {   "id":"/en/ncis",   "/user/jamie/extension/tv_episode": null } Desired Data: "name":"Faith" "airdate": "Dec/15/2009" "id":"/authority/tvrage/episode/1064868143"
  • 28. TV Rage Episode Adapter
  • 29. http://services.tvrage.com/tools/quickinfo.php?show=NCIS Show ID@4628 Show Name@NCIS Show URL@http://www.tvrage.com/NCIS Premiered@2003 Started@Sep/23/2003 Ended@ Latest Episode@07x09^Child's Play^Nov/24/2009 Next Episode@07x10^Faith^Dec/15/2009 RFC3339@2009-12-15T20:00:00-5:00 GMT+0 NODST@1260921600 Country@USA Status@Returning Series Classification@Scripted Genres@Action | Crime | Drama | Military/War Network@CBS Airtime@Tuesday at 08:00 pm Runtime@60
  • 30. TV Episode Adapter eMQL Driver TV Rage Time query dispatched pre eMQL MQL Query Extend MQL query to retrieve TV Rage Key (program identifier) updated MQL query Adapter TV Rage Service run MQL query MQL results Life Cycle fetch get series data next episode number, name,date get episode data next episode URL format results results return query results
  • 31. Using Foreign Identifiers to locate Freebase Topics • /authority Namespace • Organizations managing stable entity identifiers • /source - identifiers only appearing in URLs • Keys can be for URLs to other sites • And vice-versa!
  • 32. URLs and Freebase Keys • http://www.imdb.com/title/tt0083658 • /authority/imdb/title/tt0083658 • http://www.rottentomatoes.com/alias?type=imdbid&s=0083658 • http://dbpedia.org/resource/Blade_Runner • /wikipedia/en/Blade_Runner • http://en.wikipedia.org/wiki/Blade_Runner • http://musicbrainz.org/artist/2c4dae8c- e591-49e0-9c5a-62b310a15788.html • /authority/musicbrainz/2c4dae8c- e591-49e0-9c5a-62b310a15788 • http://www.bbc.co.uk/music/artists/2c4dae8c- e591-49e0-9c5a-62b310a15788
  • 33. http://ids.freebaseapps.com
  • 34. Using Freebase RDF URIs http://rdf.freebase.com/ns/<freebase-key> • Performs content negotiation (HTTP ACCEPT Header) • Produces HTML for standard browsers • Produces RDF if you ask for it • Easily translated to MQL style Freebase identifiers http://rdf.freebase.com/ns/en.ncis = /en/ncis
  • 35. Entity Extractors • Zemanta • Freebase RDF URIs • Wikipedia Links • IMDB identifiers • Orchestr8 • Freebase RDF URIs • DBPedia RDF URIs • MusicBrainz identifiers • Crunchbase identifiers • OpenCalais • Freebase RDF URIs • DBPedia RDF URIs
  • 36. Getting Started++ • Freebase Documentation Hub • http://www.freebase.com/docs • Developer Mailing List • http://freebase.markmail.org/search/?q=list:com.freebase.developers • Schema/Modeling assistance • Data Modeling Mailing List • http://freebase.markmail.org/search/?q=list:com.freebase.data-modeling • Real Time help on IRC • Freenode #freebase • Freebase Happenings • http://blog.freebase.com

×