[Versa] Versa issue: subgraph primitives?
Uche Ogbuji
uche.ogbuji at fourthought.com
Mon Aug 15 10:15:06 MDT 2005
On Sat, 2005-08-13 at 10:22 -0400, Chimezie Ogbuji wrote:
> > IMO, if we accept subgraphs as first-class objects, then we should dump
> > statements as separate first-class objects. A statement is, of course,
> > just a special case of a subgraph.
>
> Yes, but then you would essentially only have the capability on a
> subgraph that you would on a model (still no statement-level query
> semantics).
Not necessarily. You could define subject($subgraph) to return all
subjects of statements in that model, etc. Then for the case of
single-statement subgraph, we still have the expected semantics. Well,
we almost do. The main thorn is that subject($subgraph) would have to
return a list in that case, and that would be a bit of a hurdle when you
know you're just dealing with single statements. Given automated data
type conversion from list-of-one-item to just-the-item, this might not
be a problem.
I just want to think through the possibility. I'm not wedded to it.
> In the example I was thinking of chaining the results to
> subsequent queries programatically (outside of Versa). However, I had
> added a scoped-subquery function to 4RDF's Versa implementation at
> some point which seems to cover *some* of the requirements of working
> with subgraphs as first class objects, the difference being that it
> just dealt with subgraph 'names' not subgraphs directly. But if you
> allowed a mechanism to name (perhaps with an anonymouse/transient uri)
> a temporary result subgraph, you could then use
> scoped-subquery(expression,subgraphName) to evaluate expressions on
> subgraph results.
Yes, this last sentence of yours is precisely where I think there might
be gold worth mining for.
> > Traversal expressions would return a subgraph rather than a list of
> > statements (or scalars right now).
>
> So all() |- dc:title -> contains('Article') would return a subgraph
> containing all dc:title statements containing 'Article'? Then you
> could do:
>
> scoped-subgraph('type(xsd:string)','all() |- dc:title -> contains('Article')')
>
> to get all such titles?
something along those lines, yes.
> > As chime says, this would allow for
> > very elegant composition, e.g. in chaining Versa queries.
>
> On that note, I found it incredibly useful to implement a query-chain
> function (which went along way in allowing me to limit how much work
> is done by the host language - which was doing more work than I
> thought it should for my taste) which allows explicit chaining of
> versa queries. Emeka currently is capable of such queries:
>
> <chimezie> .help query-chain
> <Emeka> query-chain(string,[string, [...]])
> <Emeka> Treats each of it's arguments as the string representation of
> a Versa expression (each of which is compiled and
> evaluated in the order given). The results of successive
> evaluations are bound to variables of the form resultN,
> where N is the index/number of the expression evaluated.
> Each expression is evaluated with the prior result as
> the context node and with all the previous results available
> as variables (result1,result2,..,resultN).
>
> <chimezie> .query $chimeziesBookmarks
> "query-chain('list("chime","ogbuji")','filter(.,"contains(\'og\')")')"
> <Emeka> Querying against 469 triples
> <Emeka> [u'ogbuji']
That sounds useful, and worth bookmarking for further discussion. I'm
sure we can generalize the case even more.
--
Uche Ogbuji Fourthought, Inc.
http://uche.ogbuji.net http://fourthought.com
http://copia.ogbuji.net http://4Suite.org
Use CSS to display XML, part 2 - http://www-128.ibm.com/developerworks/edu/x-dw-x-xmlcss2-i.html
XML Output with 4Suite & Amara - http://www.xml.com/pub/a/2005/04/20/py-xml.html
Use XSLT to prepare XML for import into OpenOffice Calc - http://www.ibm.com/developerworks/xml/library/x-oocalc/
Schema standardization for top-down semantic transparency - http://www-128.ibm.com/developerworks/xml/library/x-think31.html
More information about the Versa
mailing list