26 October 2009

Up and running with Mercurial

Quick and easy.

spacer

I've used the cvs and svn version control systems for both work-related and personal projects. For personal work, I used svn in particular more as a backup program, with the added benefit of the version control. Keeping my repository on a thumb drive made it easy to perform the backups when traveling, but perhaps because of sloppiness in removing the thumb drive without clicking the right icons first, my repository got corrupted too often, so I gave up.

I decided to try again with Mercurial and was shocked at how quickly I was able to learn it and get it to do everything I wanted—about an hour. This blog posting convinced me to try it before git, which sounds fascinating but a bit more complicated. By keeping my repository on the local drive and using the clone feature to keep backup copies of the repository elsewhere, I can redo a backup if a thumb drive version gets messed up.

The Mercurial Quick Start lives up to its name, and I kept some notes as I went along to provide my own Mercurial quick reference:

hg initTurn current directory into a project.
hg addAdd files in current directory to repository.
hg ci -m "comment about this commit"Commit recent changes to repository.
hg clone . e:\otherCopyCreate a clone of the current directory's repository somewhere else.
hg push e:\otherCopy Send recent changes in this directory's repository to a clone repository (that is, back up the changes here to there).
update(entered from within e:\otherCopy directory) Make clone directory's contents reflect recent changes to clone repository.
hg log test1.txtList comments (see -m above) for each of test1.txt file's changes.
hg revert -r 1 test1.txt Revert file test1.txt to revision 1. (You can then "revert" it to later versions.
hg cat -r 2 test1.txt Look at version 2 of test1.txt.
hg locate *foo*List files in repository with "foo" in their names.

One other note: an .hgignore file tells hg files which to ignore, and putting separate .htignore files in subdirectories of your main project directory works fine.

I once had grand ideas about hooking up a version control system that can assign arbitrary metadata with an RDF triplestore to form the basis of some sort of CMS demo. Mercurial isn't much help here, but when I prioritize the tasks "back up my stuff" and "build a demo CMS around a version control system" the former is clearly much more important. Maybe someday...

Posted by Bob DuCharme at 9:50 AM | Permalink | Comments (4) | TrackBacks (0)

14 October 2009

Blogging on TopQuadrant's Blog

In addition to here.

I just added my first entry to TopQuadrant's blog, Voyages of the Semantic Enterprise. It's called SPIN Tutorial Available, and describes the tutorial I recently finished writing on using the SPARQL Inferencing Notation with TopBraid Composer.

I'll be adding more to that blog in the future and certainly continuing with this one here, keeping the entries that focus on TopQuadrant technology over there. I'll put the others—including more general interest entries on the semantic web, SPARQL, and RDF—right here.

Thanks for reading either!

Posted by Bob DuCharme at 7:59 PM | Permalink | Comments (1) | TrackBacks (0)

1 October 2009

A rules language for RDF

Right under our noses.

Last May, in Adding semantics to make data more valuable: the secret revealed, I showed how storing a little bit of semantics about the word "spouse"—the fact that it's a symmetric property (that is, that if A is the spouse of B, then B is the spouse of A)—let me look up someone's home phone number in my address book even if my entry for him there lacks his home phone number. I like this story because unlike biotech and some of the other popular domains for Semantic Web technology, everyone has an address book and understands the basic properties of an entry: first name, last name, email address, and so forth. (Because so many people have lived through the annoyances of moving their contact information from one email client or phone to another, address books also provide nice use cases for data integration issues.)

Back then, I wrote:

With software that understands an OWL expression stating that spouse is a symmetric property and a rule I define to say that spouses have the same home phone number, I can retrieve Leroy's home phone number...

OWL is great for defining the symmetry, but I glossed over the part about defining the fact that spouses have the same phone number. How do you define such a rule? n3 has a rules language, but I haven't seen it used much as the n3 subset known as Turtle (which leaves out such things) becomes more popular. Instead of defining a Semantic Web rules language, the W3C has decided to have the Rules Interchange Format Working Group standardize an interchange format between the many rules languages out there. (The W3C Rules Interchange Format Basic Logic Dialect PowerPoint presentation by WG co-chair Chris Welty provides good historical background.)

I can write a query that generates the triples I want to infer and call this query a "rule", but what do I do with it?

I've used a proprietary RDF rules language before, and was wondering if a standard one would come along. Some colleagues at TopQuadrant have shown me that we all have a straightforward, standardized RDF rules language right under our noses: SPARQL. I've been appreciating SPARQL's CONSTRUCT form more lately, and CONSTRUCT is the key here: like a SELECT statement, a CONSTRUCT statement defines conditions about which pieces of which triples to retrieve, but unlike SELECT, a CONSTRUCT statement assembles these into new triples. If we view a CONSTRUCT statement as the definition of a rule and the resulting new triples as the result of the execution of the rule, then we have a rules language and plenty of implementations of it available.

For example, the following SPARQL "rule" says that if ?person1 has the spouse ?person2 and the home telephone number ?phoneNum, then ?person2 also has the home telephone number ?phoneNum:

PREFIX  : <www.snee.com/ns/demo#>
PREFIX v: <www.w3.org/2006/vcard/ns#>

CONSTRUCT { ?person2 v:homeTel ?phoneNum . }
WHERE {
  ?person1 :spouse   ?person2 ;
           v:homeTel ?phoneNum .
}

When run with the following data (for the purposes of this demo, assume that the {:leroy :spouse :loretta} triple was generated by an OWL reasoner that saw {:loretta :spouse :leroy} and knew that :spouse was symmetrical),

@prefix  : <www.snee.com/ns/demo#> .
@prefix v: <www.w3.org/2006/vcard/ns#> .
:loretta :spouse   :leroy ;
         v:homeTel "434-923-9321" .
:leroy   v:workTel "434-932-5329" ;
         :spouse   :loretta .

It generates the triple {:leroy v:homeTel "434-923-9321"}.

OK, so I can write a query that generates the triples I want to infer and call this query a "rule", but what do I do with it? What makes it a rule about a particular set of data?

Holger Knublauch, a co-worker of mine who designed and developed the OWL plugin for Protégé before coming to TopQuadrant, recently wrote an RDF vocabulary called SPIN ("SPARQL Inferencing Notation"), which—among other things—can express associations between these rules and classes. So, for example, if the blank node rdf:_1 pointed to the query above, the following triple would associate this query rule to the v:Address class:

  v:Address spin:rule rdf:_1

To make the storage of the SPARQL rule in a triplestore even cleaner, Holger has implemented a way to store SPARQL queries as triples, and he's written the code to roundtrip between this and the standard text version. (See the SPARQL Text to SPIN RDF Syntax Converter for an online converter, and see spinrdf.org for more about what else the SPIN vocabulary can do, especially his blog entries as he developed it. I'm now finishing up a tutorial for the use of SPIN features in TopQuadrant products, and except for one optional step of the tutorial, it all works with the free version of TopBraid Composer.)

When you take it a little further, symmetrical properties and many other parts of OWL can also be implemented with SPARQL queries, and there's a lot going on among those who are doing this to find a sweet spot between RDFS and OWL Full that meets typical business needs without using a lot of processing power or dollars.

Posted by Bob DuCharme at 12:45 PM | Permalink | Comments (6) | TrackBacks (0)

Recent Posts

  • Up and running with Mercurial
  • Blogging on TopQuadrant's Blog
  • A rules language for RDF
  • Converting wpl playlists to m3u playlists
  • Appreciating SPARQL CONSTRUCT more

Recent Tweets

    Popular Posts

    • Windows command line text processing with Javascript
    • Creating epub files
    • An Apple eBook reader?
    • The future of RDFa
    • Free epub children's picture books
    • Scraping and linked data
    • Accessibility problems with microformats
    • Simple flowcharts in Excel
    • Reading epub files with the Sony PRS-505 ebook reader
    • Digging RDFa

    Recent Articles

    devX.com: Using RDFa with DITA and DocBook

    IBM developerWorks: Build Wikipedia query forms with semantic technology

    devX.com: Building an Application with the Twitter API

    devX.com: Getting Started with the Twitter API

    Links

    • Bob's home page
    • older weblog on linking-related issues
    • FOAF file

    Categories

    • XBRL
    • XML
      • DITA
      • XSLT
    • blogging about blogging
    • book reviews
    • metadata
      • RDF
        • SPARQL
        • triplestores
      • RDF/OWL
      • semantic web
        • project ideas
    • miscellaneous
    • music
    • neat tricks
    • publishing
      • documenting software
      • ebooks
      • legal publishing
    • technology, future
    • technology, past
    • tourism

    Archives

    • October 2009
    • September 2009
    • August 2009
    • July 2009
    • June 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
    • September 2008
    • August 2008
    • July 2008
    • June 2008
    • May 2008
    • April 2008
    • March 2008
    • February 2008
    • January 2008
    • December 2007
    • November 2007
    • October 2007
    • September 2007
    • August 2007
    • July 2007
    • June 2007
    • May 2007
    • April 2007
    • March 2007
    • February 2007
    • January 2007
    • December 2006
    • November 2006
    • October 2006
    • September 2006
    • August 2006
    • July 2006
    • June 2006
    • May 2006
    • April 2006
    • March 2006
    • February 2006
    • January 2006
    • December 2005
    • November 2005

    Feeds spacer -->

    [What are these?]
    Atom 1.0 (summarized entries)
    Atom 1.0 (full entries)
    RSS 1.0
    RSS 2.0
    gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.