Spiral Version 0.34

This minor release adds support for optional query patterns. Optional patterns are ones that attempt to match triples but do not fail the query if no match is possible. This is still quite a low-level implementation as the Sparql parser is still being written. For the moment you have to build the underlying objects yourself.

For example, to represent a query like:


?subj <http://example.com/property > ?obj .
OPTIONAL { ?subj <http://example.com/other > ?obj2 . }

You would need to write:


  Query query = new Query();

  query.AddPattern( 
    new Pattern( 
      new Variable("subj"),  
      new UriRef("http://example.com/property"), 
      new Variable("obj") 
    ) 
  );

  query.AddOptionalPattern( 
    new Pattern( 
      new Variable("subj"),  
      new UriRef("http://example.com/other"), 
      new Variable("obj2") 
      ) 
    );

To process it you would do the following:


  IEnumerator solutions = tripleStore.Solve( query );
  
  while (solutions.MoveNext() ) {
    QuerySolution solution = (QuerySolution)solutions.Current;
    
    Console.WriteLine("Subject is " + 
      tripleStore.GetBestDenotingNode( solution["subj"] ).GetLabel() );
      
    Console.WriteLine("Property value is " + 
      tripleStore.GetBestDenotingNode( solution["obj"] ).GetLabel() );

    Console.WriteLine("Other value is " + 
      tripleStore.GetBestDenotingNode( solution["obj"] ).GetLabel() );

  }

Work is ongoing to support the Sparql syntax and cleaner result handling.

About Spiral: Spiral is an RDF processing framework targetted at the .NET and mono platforms and is made freely available under a liberal MIT-style license. There is no unmanaged code and so should work in every environment supported by .NET or mono. It provides a set of classes to represent the RDF model, implementations of in-memory and mySQL triple stores, an RDF/XML parser, multi-pattern querying and a simple rules system. Early support for Sparql syntax has recently been added. More about Spiral…

Comments

No comments yet.

Leave a comment

Sorry, the comment form is closed at this time.