Re: Triple Store / RDF

2006-06-22 Thread Phil Powell

On 22/06/06, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> I guess mine was more of a combination. I wrote an interface that was
> similar to the querying interface in Django at the time (0.90 / 0.91
> style). Give it keyword args of what to select and triples describing
> the filtering conditions. So I could write things like
>
> get_object(values = ['?x', '?y'],
>where = ['?x has ?y', '?y is red'])

I found myself using Rubys hash objects and string literals to quite
good effect for building quite complex queries, so for example (excuse
the bad code):

Resource.find(:all, :user => {:first_name => 'John', :surname => 'Doe'})

And then you could go one better with:

Resource.find(:all, :article => {
  :user => {:first_name => 'John', :surname => 'Doe'},
  :subject => 'rdf'
})

I wonder how that would look in Python...?

> In my infinite spare time, perhaps...

Hmmm, spare time? What an interesting concept ;)

-Phil

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Triple Store / RDF

2006-06-22 Thread Malcolm Tredinnick

Hi Phil,

On Thu, 2006-06-22 at 13:51 +0100, Phil Powell wrote:
> Thanks Malcolm.  I'm curious more than anything, since RDF etc gets
> talked about a lot, but implementations rarely seem to make it into
> the real-world.

For me, RDF is one of those things that I try to keep up to speed with,
because one day I will need it professionally. And it's fun to play
with. But I've never had to use it in anger so far.

> 
> I referenced the exact same resource to pull together a basic
> triple-store library in Rails a while back, and it was fairly painless
> (although a tad hacky) - perhaps I'll sit down to try the same with
> Python and Django sometime.  I certainly found the code I had working
> to be VERY powerful.
> 
> Just out of curiosity, did you use a SPARQL-style syntax to build
> queries, then convert it into standard SQL?  Or did you do what I did,
> and have an object-based API translate to SQL without a middle-man?

I guess mine was more of a combination. I wrote an interface that was
similar to the querying interface in Django at the time (0.90 / 0.91
style). Give it keyword args of what to select and triples describing
the filtering conditions. So I could write things like

get_object(values = ['?x', '?y'],
   where = ['?x has ?y', '?y is red'])

That was then converted into real Django queries on the model using the
algorithm in the article we both found.

Looking at the code just now, it seems like I never had to implement the
equivalent of "from" because everything was essentially in one model.
One of the advantages of toy projects. :-)

Hmm.. this makes me want to play with this again. An API using the
current Django models and managers stuff could look very nice. In my
infinite spare time, perhaps...

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Triple Store / RDF

2006-06-22 Thread Phil Powell

Thanks Malcolm.  I'm curious more than anything, since RDF etc gets
talked about a lot, but implementations rarely seem to make it into
the real-world.

I referenced the exact same resource to pull together a basic
triple-store library in Rails a while back, and it was fairly painless
(although a tad hacky) - perhaps I'll sit down to try the same with
Python and Django sometime.  I certainly found the code I had working
to be VERY powerful.

Just out of curiosity, did you use a SPARQL-style syntax to build
queries, then convert it into standard SQL?  Or did you do what I did,
and have an object-based API translate to SQL without a middle-man?

-Phil

On 19/06/06, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> On Mon, 2006-06-19 at 12:35 +0100, Phil Powell wrote:
> > Hi all,
> >
> > Just out of pure curiosity: has anyone had any experience / know of
> > any work around using RDF / triple stores with Django?
>
> This was the "toy project" I used to get familiar with Django in about
> October last year (aah.. the memories). I made up a model and some
> auxilliary methods based around [1] and a simple web page so that I
> could run queries. It was a "learning Django" exercise, rather than
> aimed at doing anything useful, so I didn't take it very far or try to
> optimise it much. Might be fun to revisit with the latest Django changes
> (the original code would not run any more), because some of the more
> RDF-like interfaces could be put into the model managers and the like,
> making it a bit more seamless.
>
> [1] http://www.picdiary.com/triplequerying/
>
> There wasn't really anything specially hard about this. The model was as
> simple as it gets and trying out possibilities for the API was the
> interesting part.
>
> Regards,
> Malcolm
>
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Triple Store / RDF

2006-06-19 Thread Malcolm Tredinnick

On Mon, 2006-06-19 at 12:35 +0100, Phil Powell wrote:
> Hi all,
> 
> Just out of pure curiosity: has anyone had any experience / know of
> any work around using RDF / triple stores with Django?

This was the "toy project" I used to get familiar with Django in about
October last year (aah.. the memories). I made up a model and some
auxilliary methods based around [1] and a simple web page so that I
could run queries. It was a "learning Django" exercise, rather than
aimed at doing anything useful, so I didn't take it very far or try to
optimise it much. Might be fun to revisit with the latest Django changes
(the original code would not run any more), because some of the more
RDF-like interfaces could be put into the model managers and the like,
making it a bit more seamless.

[1] http://www.picdiary.com/triplequerying/

There wasn't really anything specially hard about this. The model was as
simple as it gets and trying out possibilities for the API was the
interesting part.

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---