All Projects → nchah → freebase-mql

nchah / freebase-mql

Licence: other
A review of the deprecated Freebase knowledge base and Metaweb Query Language (MQL). A brief comparison of MQL and GraphQL.

Projects that are alternatives of or similar to freebase-mql

Hypergraphql
GraphQL interface for querying and serving linked data on the Web.
Stars: ✭ 120 (+192.68%)
Mutual labels:  query-language
EA-MQL4
MQL4编程实现外汇自动化交易
Stars: ✭ 69 (+68.29%)
Mutual labels:  mql
grafito
Portable, Serverless & Lightweight SQLite-based Graph Database in Arturo
Stars: ✭ 95 (+131.71%)
Mutual labels:  query-language
Cql
CQL: Categorical Query Language implementation in Haskell
Stars: ✭ 132 (+221.95%)
Mutual labels:  query-language
EA31337-classes
📦📈 EA31337 framework (MQL library for writing trading Expert Advisors, indicators and scripts)
Stars: ✭ 103 (+151.22%)
Mutual labels:  mql
fat ecto
Query mechanism for Ecto
Stars: ✭ 20 (-51.22%)
Mutual labels:  query-language
Pgql Lang
PGQL is an SQL-based query language for the Property Graph data model
Stars: ✭ 114 (+178.05%)
Mutual labels:  query-language
cql
Clincal Quality Language Specification
Stars: ✭ 16 (-60.98%)
Mutual labels:  query-language
TradingTool-Wiki
Wiki for all TradingToolCrypto Products. MetaTrader 5 trading tools: Indicators, robots, risk management, signals, custom coding, CrptoBridgePro , and more
Stars: ✭ 26 (-36.59%)
Mutual labels:  mql
mt4-expander
DLL extension for the MetaTrader MQL4 framework
Stars: ✭ 25 (-39.02%)
Mutual labels:  mql
Emuto
manipulate JSON files
Stars: ✭ 180 (+339.02%)
Mutual labels:  query-language
mt4-websockets
Turns Metatrader4 into web socket client
Stars: ✭ 20 (-51.22%)
Mutual labels:  mql
Judge-Jury-and-Executable
A file system forensics analysis scanner and threat hunting tool. Scans file systems at the MFT and OS level and stores data in SQL, SQLite or CSV. Threats and data can be probed harnessing the power and syntax of SQL.
Stars: ✭ 66 (+60.98%)
Mutual labels:  query-language
Ldflex
A JavaScript DSL for querying Linked Data on the Web
Stars: ✭ 123 (+200%)
Mutual labels:  query-language
kql
Kirby's Query Language API combines the flexibility of Kirby's data structures, the power of GraphQL and the simplicity of REST.
Stars: ✭ 120 (+192.68%)
Mutual labels:  query-language
Groq
Specification for GROQ - Graph-Relational Object Queries
Stars: ✭ 117 (+185.37%)
Mutual labels:  query-language
Median-and-Turbo-Renko-indicator-bundle
MQL5 header file for 'Median and Turbo renko indicator bundle' available for MT5 via MQL5 Market. The file lets you easily create a Renko EA in MT5 using the Median Renko indicator.
Stars: ✭ 68 (+65.85%)
Mutual labels:  mql
weedow-searchy
Automatically exposes web services over HTTP to search for Entity-related data using a powerful query language
Stars: ✭ 21 (-48.78%)
Mutual labels:  query-language
JAson
Creation a JSON object with data of different types and run serialization and deserialization of JSON data.
Stars: ✭ 38 (-7.32%)
Mutual labels:  mql
djaq
Django queries
Stars: ✭ 54 (+31.71%)
Mutual labels:  query-language

freebase-mql

A review of Freebase.com and the (now deprecated) Metaweb Query Language (MQL). This repo is a response to the increasing attention being given to Facebook's GraphQL, which was released in September 2015. Those who are familiar with MQL may have immediately noticed the similiarities of GraphQL with this now deprecated language.

Freebase

The Freebase Wikipedia article provides a good overview of the knowledge base's nearly decade-long lifetime from its beginnings at Metaweb Technologies, Inc. in 2007, its acquisition by Google in 2010, and its eventual shutdown and move to Wikidata towards 2015-2016. Freebase data could be accessed through the Freebase API and the online Query Editor with queries written in the Metaweb Query Language (MQL).

Although the shutdown of freebase.com was set for as early as June 30, 2015 according to this initial Google+ post, the actual website was still accessible for quite a long time. On May 2, 2016, freebase.com was finally closed off as announced in this Google Group post. The freebase.com link now redirects to the Google Developers page for the remaining Freebase triples data dumps.

A screenshot of freebase.com on May 2, 2016 before it was shut down. freebase.com screenshot

What Remains: Freebase Data Dumps

A data dump of 1.9 billion Freebase triples in N-Triples RDF format is available on the developers page under the CC-BY license. The freebase.com URL also redirects to this page following its shutdown. The file is listed as 22 GB gzip compressed and 250 GB uncompressed on the website, but recent downloads may exceed this size (a May 2016 download amounted to >30 GB compressed and >400 GB uncompressed).

Examining the compressed data with Z commands:

# Scan through the data with zmore or zless
$ zmore freebase-rdf-latest.gz

<http://rdf.freebase.com/ns/american_football.football_player.footballdb_id>    <http://rdf.freebase.com/ns/type.object.type>   <http://rdf.freebase.com/ns/type.property>      .
<http://rdf.freebase.com/ns/american_football.football_player.footballdb_id>    <http://rdf.freebase.com/ns/type.object.name>   "footballdb ID"@en      .
<http://rdf.freebase.com/ns/american_football.football_player.footballdb_id>    <http://rdf.freebase.com/ns/type.property.unique>       "true"  .
<http://rdf.freebase.com/ns/american_football.football_player.footballdb_id>    <http://rdf.freebase.com/ns/type.property.expected_type>        <http://rdf.freebase.com/ns/type.enumeration>   .
<http://rdf.freebase.com/ns/american_football.football_player.footballdb_id>    <http://www.w3.org/2000/01/rdf-schema#label>    "footballdb ID"@en      .

# You can also grep it
$ zgrep '/ns/film.film>' -m 5 freebase-rdf-latest.gz

<http://rdf.freebase.com/ns/film.film_song_relationship.film>   <http://rdf.freebase.com/ns/type.property.expected_type>    <http://rdf.freebase.com/ns/film.film>  .
<http://rdf.freebase.com/ns/film.film_song_relationship.film>   <http://www.w3.org/2000/01/rdf-schema#range>    <http://rdf.freebase.com/ns/film.film>  .
<http://rdf.freebase.com/ns/g.112ygbz6_>    <http://rdf.freebase.com/ns/type.object.type>   <http://rdf.freebase.com/ns/film.film>  .
<http://rdf.freebase.com/ns/g.112ygbz6_>    <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>   <http://rdf.freebase.com/ns/film.film>  .
<http://rdf.freebase.com/ns/g.113qbnjlk>    <http://rdf.freebase.com/ns/type.object.type>   <http://rdf.freebase.com/ns/film.film>  .

License

Freebase data is licensed under the CC-BY license. The Freebase API also has additional Terms and Conditions.

Metaweb Query Language (MQL)

The Metaweb Query Language is covered briefly as a part of the Freebase Wikipedia article.

For additional insight, MQL was explained by a Metaweb engineer barakmich on a discourse.cayley.io technical discussion in July 9, 2016:

Metaweb

When Metaweb was getting started, there was graphd. It had a nigh-incomprehensible query language, GQL, that, the theory went, was easy for machines to compile to. As a separate service, we ran MQL, which compiled user and client queries into GQL and parsed the result back out again into . For reference, I joined in early 2008. MQL is an approximately late 2006 into 2007 creation and the query language to graphd predates that a bit.

...

MQL

Anyway, to actually make something for developers, there was the Metaweb Query Language, MQL. The idea was to leverage JSON -- an uncertain bet, at the time, when JSON was still not quite a de-facto lingua franca. JSON, combined with judicious semantics around objects, nulls, keys, and values

The rest of the write up goes over MQL in even more detail, covering various positive and negative points. Interestingly, a look back at MQL years after it was deprecated brings up some nice similarities with the more recent GraphQL by Facebook, as per this comment:

...

I want to call out how insightful it was for its day. It did JSON queries before they were cool. A tree template maps onto a graph (barring a few more advanced cases) in a surprisingly useable way. It was clever and fun. You could do a lot with a little.

There are some clear parallels to what I know about GraphQL, incidentally; a tree-structured template in a language that looks designer-friendly smells a lot like MQL. I'm not sure how to fully reconcile the ideas, though. Open question.

MQL was being rewritten from the ground-up when we were acquired.

MQL and GraphQL

Some samples of MQL scripts that I wrote are enclosed as txt files in the mql-queries folder. At the time, I used Python scripts to query the Freebase API with the MQL requests. Due to Python requirements, "None" may need to be replaced with "null" to convert it back into a "pure" MQL query.

The MQL Reference Guide presents the following as a first query using MQL.

	Query:
	{
	  "type" : "/music/artist",
	  "name" : "The Police",
	  "album" : []
	}

	Response:
	{
	  "type": "/music/artist",
	  "name": "The Police",
	  "album": [
	    "Outlandos d'Amour",
	    "Reggatta de Blanc",
	    "Zenyatta Mondatta",
	    "Ghost in the Machine",
	    "Synchronicity",
	  ]
	}

In comparison, the GraphQL documentation offers the following introductory query:

	Query:
	{
	  user(id: 3500401) {
	    id,
	    name,
	    isViewerFriend,
	    profilePicture(size: 50)  {
	      uri,
	      width,
	      height
	    }
	  }
	}

	Response:
	{
	  "user" : {
	    "id": 3500401,
	    "name": "Jing Chen",
	    "isViewerFriend": true,
	    "profilePicture": {
	      "uri": "http://someurl.cdn/pic.jpg",
	      "width": 50,
	      "height": 50
	    }
	  }
	}

The syntax is not exactly the same, but there are notable similarities in the general nested structure and query format. The query request essentially lays out the data structure that should be returned in the response.

As of late 2016, GraphQL continues to be a topic that is brought up on some notable technical forums: Hacker News (Search), Reddit's /r/programming (Search).

More MQL

These are some further MQL queries. In most cases I have commented out the "return" parameter with "#" (due to the MQL being originally written in Python scripts). The "limit" parameter is also set to a reasonable amount and would have been adjusted accordingly.

Get all food dish topics (topics with /food/dish type):

{
    "name": None,
    "mid": None,
    "type": "/food/dish",
    "count": None,
    #"return": "count",
    "limit": 20,
    "sort": "name",
}

Get food dish topics and their ingredients:

{
    "name": None,
    "mid": None,
    "type": "/food/dish",
    "ingredients": [{
        "mid": None,
        "name": None,
        }],
    "count": None,
    #"return": "count",
    "limit": 100,
    "sort": "name",
}

Get cuisine topics' dishes and their ingredients:

{
    "name": None,
    "mid": None,
    "type": "/dining/cuisine",
    "dishes": [{
        "type": "/food/dish",
        "ingredients": [{
            "mid": None,
            "name": None,
            }],
        "name": None,
        "mid": None,
        "count": None,
        }],
    "count": None,
    #"return": "count",
    "limit": 100,
    "sort": "name",
}

. . .

From Freebase to Google's Knowledge Graph

Following the deprecation of the Freebase APIs, the new Knowledge Graph Search API (KG API) was released by Google on December 16, 2015 (Google+ post). As of April 2016, the new KG API does not support queries written in MQL as it once did on Freebase.

Sources

Some sources may no longer be available following the deprecation of the Freebase API on June 30, 2015.

Announcements Timeline

Many Freebase and Knowledge Graph related updates are posted on the once active freebase-discuss Google Group and the Google+ community.

Freebase and MQL

Knowledge Graph

Google Developers Resources

Freebase API

Knowledge Graph Search API

Google Search

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].