| |
- RDFSink
-
- RDFStructuredOutput
- TracingRDFSink
- exceptions.ValueError(exceptions.StandardError)
-
- URISyntaxError
class RDFSink |
|
interface to connect modules in RDF processing.
OBSOLETE
This is a superclass for other RDF processors which accept RDF events
or indeed Swell events. It is superceded, effectively, by the class Formula,
as a sink of data and a soiurce of new symbols.
Keeps track of prefixes.
This interface has the advantage that it does n ot have any dependencies
on object types, it is really one-way (easily serialized as no return values).
It has the disadvantages that
- It uses the pseudoproperties log:forSome and log:forAll to
make variables, which is a bit of a kludge.
- It may involve on the receiver side the same thing being interned
many times, which wastes time searching hash tables.
The superclass handles common functions such as craeting new arbitray
identifiers |
|
Methods defined here:
- __init__(self, genPrefix=None)
- If you give it a URI prefix to use for generated IDs it
will use one; otherwise, it will use the name of an imaginary temporary file
in the current directory.
- bind(self, prefix, uri)
- Pass on a binding hint for later use in output
This really is just a hint. The parser calls bind to pass on
the prefix which it came across, as this is a useful hint for
a human readable prefix for output of the same
namespace. Otherwise, output processors will have to invent or
avoid useing namespaces, which will look ugly
- checkNewId(self, uri)
- The store can override this to raise an exception if the
id is not in fact new. This is useful because it is usfeul
to generate IDs with useful diagnostic ways but this lays them
open to possibly clashing in pathalogical cases.
- countNamespace(self, namesp)
- On output, count how many times each namespace is used
- endDoc(self, rootFormulaPair)
- End a document
Call this once only at the end of parsing so that the receiver can wrap
things up, oprimize, intern, index and so on. The pair given is the (type, value)
identifier of the root formula of the thing parsed.
- genId(self)
- intern(self, something)
- makeComment(self, str)
- This passes on a comment line which of course has no semantics.
This is only useful in direct piping of parsers to output, to preserve
comments in the original file.
- makeStatement(self, tuple, why=None)
- add a statement to a stream/store.
raises URISyntaxError on bad URIs
tuple is a quad (context, predicate, subject, object) of things generated by calls to newLiteral etc
why is reason for the statement.
- namespaceCounts(self)
- newBlankNode(self, context, uri=None, why=None)
- newExistential(self, context, uri=None, why=None)
- newFormula(self, uri=None)
- newList(self, l, context)
- newLiteral(self, str, dt=None, lang=None)
- newSymbol(self, uri)
- newUniversal(self, context, uri=None, why=None)
- newXMLLiteral(self, doc)
- reopen(self)
- Un-End a document
If you have added stuff to a document, thought you were done, and
then want to add more, call this to get back into the sate that makeSatement
is again acceptable. Remember to end the document again when done.
- setDefaultNamespace(self, uri)
- Pass on a binding hint for later use in output
This really is just a hint. The parser calls this to pass on
the default namespace which it came across, as this is a
useful hint for a human readable prefix for output of the same
namespace. Otherwise, output processors will have to invent or
avoid useing namespaces, which will look ugly.
- setGenPrefix(self, genPrefix)
- startDoc(self)
|
class RDFStructuredOutput(RDFSink) |
| |
Methods defined here:
- endAnonymous(self, subject, verb)
- endAnonymousNode(self, endAnonymousNode)
- endFormulaObject(self, pred, subj)
- endFormulaSubject(self, subj)
- startAnonymous(self, triple, isList=0)
- startAnonymousNode(self, subj)
- startFormulaObject(self, triple)
- startFormulaSubject(self, context)
Methods inherited from RDFSink:
- __init__(self, genPrefix=None)
- If you give it a URI prefix to use for generated IDs it
will use one; otherwise, it will use the name of an imaginary temporary file
in the current directory.
- bind(self, prefix, uri)
- Pass on a binding hint for later use in output
This really is just a hint. The parser calls bind to pass on
the prefix which it came across, as this is a useful hint for
a human readable prefix for output of the same
namespace. Otherwise, output processors will have to invent or
avoid useing namespaces, which will look ugly
- checkNewId(self, uri)
- The store can override this to raise an exception if the
id is not in fact new. This is useful because it is usfeul
to generate IDs with useful diagnostic ways but this lays them
open to possibly clashing in pathalogical cases.
- countNamespace(self, namesp)
- On output, count how many times each namespace is used
- endDoc(self, rootFormulaPair)
- End a document
Call this once only at the end of parsing so that the receiver can wrap
things up, oprimize, intern, index and so on. The pair given is the (type, value)
identifier of the root formula of the thing parsed.
- genId(self)
- intern(self, something)
- makeComment(self, str)
- This passes on a comment line which of course has no semantics.
This is only useful in direct piping of parsers to output, to preserve
comments in the original file.
- makeStatement(self, tuple, why=None)
- add a statement to a stream/store.
raises URISyntaxError on bad URIs
tuple is a quad (context, predicate, subject, object) of things generated by calls to newLiteral etc
why is reason for the statement.
- namespaceCounts(self)
- newBlankNode(self, context, uri=None, why=None)
- newExistential(self, context, uri=None, why=None)
- newFormula(self, uri=None)
- newList(self, l, context)
- newLiteral(self, str, dt=None, lang=None)
- newSymbol(self, uri)
- newUniversal(self, context, uri=None, why=None)
- newXMLLiteral(self, doc)
- reopen(self)
- Un-End a document
If you have added stuff to a document, thought you were done, and
then want to add more, call this to get back into the sate that makeSatement
is again acceptable. Remember to end the document again when done.
- setDefaultNamespace(self, uri)
- Pass on a binding hint for later use in output
This really is just a hint. The parser calls this to pass on
the default namespace which it came across, as this is a
useful hint for a human readable prefix for output of the same
namespace. Otherwise, output processors will have to invent or
avoid useing namespaces, which will look ugly.
- setGenPrefix(self, genPrefix)
- startDoc(self)
|
class TracingRDFSink |
|
An implementation of the RDFSink interface which helps me
understand it, especially how it gets used by parsers vs. by an
RDF store. [ -sandro ]
Set .backing to be some other RDFSink if you want to get proper
results while tracing.
Try:
bash-2.04$ python cwm.py test/rules12.n3 --language=trace
bash-2.04$ python cwm.py --pipe test/rules12.n3 --language=trace
bash-2.04$ python cwm.py test/rules12.n3 --bySubject --language=trace
... and see the different outputs |
|
Methods defined here:
- __init__(self, outURI, base=None, flags=None)
- bind(self, prefix, uri)
- endDoc(self, rootFormulaPair='<<strangely omitted>>')
- endFormulaObject(self, pred, subj)
- endFormulaSubject(self, subj)
- makeComment(self, comment)
- makeStatement(self, tuple, why=None)
- newFormula(self, uri=None)
- newLiteral(self, str, dt=None, lang=None)
- newSymbol(self, uri)
- setDefaultNamespace(self, ns)
- startDoc(self)
- startFormulaObject(self, triple)
- startFormulaSubject(self, context)
|
|