[Developers] MQL Lite (was newbie: simple question)

Iain Sproat iainsproat at gmail.com
Thu Feb 26 20:38:39 UTC 2009


I'd like to point out a little side project I've just begun in C# for .Net.
 http://code.google.com/p/freebase-dotnet/
I started out wrapping the C# code from the documentation
http://www.freebase.com/view/guid/9202a8c04000641f80000000090e3aee into a
class.

But of interest to this mailing list thread is a fluent front end I've
thrown together for writing MQL directly from .Net (only Read at the
moment).  I've tried to make it as natural language as possible.
 The code wraps the Newtonsoft
Json.Net<http://james.newtonking.com/projects/json-net.aspx>
 library.

                Freebase.Query

                .Where().Name.Is("The Police")

                .Where().Type.Is("/music/artist")

                .Expect.Many("track").Which.Meets(

                        Freebase.InnerQuery

                        .Show.OneRecordFor.AllProperties

                        .Where().Name.StartsWith("Message")

                        .LimitNumberOfResults.To(1)

                );


A word of warning - I'm not a programmer by profession, and the code is just
knocked together without too much thought, testing, quality or documentation
- so don't expect too much/anything of the actual implementation.

I'm also experimenting with an LinqToFreebase syntax, but this is very
broken and doesn't currently work (problems somewhere between generic types,
Enumerators/Lists and the Json parser - I think) but the concept/idea is
there....

IQueryable<Artist> query = from artist in queryable

                where artist.Name == "The Police" &&

                artist.Type == ("/music/artist")

                select artist;


Iain (sprocketonline)

On Thu, Feb 26, 2009 at 10:29 PM, Shawn Simister <narphorium at gmail.com>wrote:

>  Pito Salas wrote:
>
> MQL is crazy complex though; anyone consider creating an MQL-lite?
> Yeah I realize the complexity is probably justified so as to be
> completely general and not assume anything, but it creates a major
> barrier to use IMO.
>
>
>  Pito,
>
> I dunno if I'd say MQL is really *that* complex. It takes some time to get
> used to the JSON structure of the queries when you're used to writing SELECT
> queries but once you get the hang of that I find it's actually pretty
> straight-forward. There is very little mandatory syntax is MQL so a query
> can be as simple as:
>
> {"capital":null, "type":"/location/country", "name":"Peru"}
>
> For me, the hardest part is getting to know all the commons data types and
> which types/properties to use for which queries. Usually the best way to do
> that is to look up a couple sample topics in Freebase and see which schema
> it uses, then you can click through to the schema to find the property IDs.
>
> For the sake of argument, I'm sure it would be possible to write some
> wrapper code to query Freebase with a more traditional SELECT query syntax
> but the challenge of knowing which properties to use would still be there
> and as you said, more complex queries might not be possible.
>
> SELECT capital FROM /location/country WHERE name = 'Peru';
>
> What features would you look for in MQL Lite? What are the parts of MQL
> that you find the hardest to learn as a beginner?
>
> Shawn
>
> _______________________________________________
> Developers mailing list
> Developers at freebase.com
> http://lists.freebase.com/mailman/listinfo/developers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freebase.com/pipermail/developers/attachments/20090227/8e991509/attachment-0001.htm 


More information about the Developers mailing list