W3C | Semantic Web | SWAP

n3

Cwm

Cwm (pronounced coom) is a general-purpose data processor for the semantic web, somewhat like sed, awk, etc. for text files or XSLT for XML. It is a forward chaining reasoner which can be used for querying, checking, transforming and filtering information. Its core language is RDF, extended to include rules, and it uses RDF/XML or RDF/N3 (see Notation3 Primer) serializations as required.

Cwm is written in python; it is part of SWAP, a Semantic Web Application Platform. It is open source under the W3C software license.

[Download cwm.tar.gz now]

Quick Reference:

Discussion -- places to talk about this

public-cwm-announce
This low-traffic is for announcements about releases of cwm software, and monthly summaries of changes to the bug/RFE list. You might find the cwm-announce RSS feed handy.
public-cwm-bugs
This is for the announcement and brief discussion/clarification of cwm bugs or Requests For Enhancement (RFE). If responding to an existing bug, only use mailers which send the refernce headers so that the threads on this mail ling list work. For new threads, please make the subject line informative, and use the word "bug" or "RFE" as appopriate. The current plan is to review changes in this monthly and send it to the announce list.
public-cwm-talk
Discussion by users and/or developers of the use and abuse of project software.
Semantic Web Interest group

Features and Tutorial

The Semantic Web Tutorial Using N3 covers features such as:

See also: Cwm command line arguments reference.

Other features are in development, and haven't been documented as thoroughly:

Environment Variables

CWM_RDF_PARSER
rdflib2rdf or sax2rdf (default). Affects the choice of RDF parser module used by cwm.

Security Issues

Be careful when using rules from an untrusted source.

Be carfeul even when using cryptography. I am not an expert but a few things to watch are:

About the name cwm

Originally, the name is from from "Closed World Machine" because it processed information in a limited space, cwm does not make any assumptions about a closed world. Think of it as defined area but with openings - like a valley.

see also Sean Palmer's guide to cwm -- sometimes it is more up to date than this!

Check out other programs which use the same language:

Development

This swap code is open source and available for those that want to play with it, but comes with no warranty.

Using CVS
from the public w3c CVS repository. Check out the whole tree to develop. This includes the test data - if you don't need that, delete the test subdirectory. Make a fresh directory where you want to put stuff from dev.w3.org.
$ cvs -d:pserver:anonymous@dev.w3.org:/sources/public login
password? anonymous
$ cvs -d:pserver:anonymous@dev.w3.org:/sources/public get 2000/10/swap
From the web
Get the files one by one. cwm.py is the main application file. You can browse the source files on the web, but this is not a practical way to install the system.

In the following, we assume $SWAP expands to the place where you have code checked out.

Test Driven Development (Don't trust the docs ;-)

The best test of works is what has been tested. So the list of files in the regression test defines the set of features which are generally checked on each checkin. Cwm developers agree that all the tests have to pass before code is checked in. To run the tests, do make in the swap/test directory. We reckon to add a test for a new bug, so that bugs don't recur in future versions.

Each subdirectory of test has its own detailed.tests file. In that you can put tests for new features. Note that the test commands are all writted to be run in $SWAP/test.

How to make a release

  1. Remember to cvs update to ensure you have any changes other people have done before running tests.
  2. A quick test that your code still works is cd $SWAP/test; make fast
  3. The test a release must pass before you make it is cd $SWAP/test; make pre-release
  4. Update the releases page with details of the new bug fixes and/or features.
  5. Edit $SWAP/Makefile

Code Overview

Cwm developers agree to keep line lengths below 80 characters, though we have some code that predates that agreement.

llyn.py - The Store

An in-memory store which does the inference. See the Formula class methods for a more or less conventional RDF API. A Forumula is a set of statements.

notation3.py - Serializing/deserializaing RDF/N3

Originally written by Dan Connolly, uses a basic RDF stream parser interface, migrating to API

The command line form (alias n3 python notation3.py; n3 -help) allows RDF to be parsed and re-output.

The module will also run as a CGI script to convert N3 to RDF M&S 1.0 - by DanC magic.

xml2rdf.py Parsing RDF/XML

Based on Python's xmllib, this parser is compatible with the RDF stream interface of, notation3.py. It completes the square of parsers and generators. Defunct. Now use sax parser and sax2rdf.py.

It has a command line mode for self-test purposes.

cwm_xxx.py - builtin modules

These are quite easy to add to. Look at a few and clone a similar one to the one you have made.

Design issues

The code above investigated and raised issues discussed in the following documents.

not to mention

Acknowledgements

Thanks to Dan Connolly for writing the first code and thereby introducing me to Python, and to him and Sean Palmer and Mark Nottingham for writing built-in function modules. Eric Prud'hommeaux wrote the remote database query and mySQL interface. Sandro Hawke has made various contributions. Yosi Scharf engineered the cwm 1.0.0 release and fixed various bugs and added SPARQL support. Thanks to Sean for his guide to cwm, as well as n3p, which is the basis for Cwm's Sparql parser.. Thanks for all on #RDFIG for being everything which is #RDFIG.

Development of cwm is supported in part by funding from US Defense Advanced Research Projects Agency (DARPA) and Air Force Research Laboratory, Air Force Materiel Command, USAF, under agreement number F30602-00-2-0593, "Semantic Web Development".

License

Cwm: http://www.w3.org/2000/10/swap/doc/cwm.html

Copyright © 2000-2004 World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University). Parts of the Sparql parser are Copyright © Sean Palmer. All Rights Reserved. This work is distributed under the W3C¨ Software License [1] in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231

Historical stuff from this page


Tim BL, with his director hat off
$Id: cwm.html,v 1.76 2009/10/20 13:06:52 syosi Exp $