[Versa] Versa issue: subgraph primitives?

Chimezie Ogbuji chimezie at gmail.com
Sat Aug 13 08:22:09 MDT 2005


> 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).  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.

> 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?

>  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']



More information about the Versa mailing list