parsers Package¶
parsers
Package¶
hturtle
Module¶
Extraction parser RDF embedded verbatim into HTML or XML files. This is based on:
- The specification on embedding turtle into html:
- http://www.w3.org/TR/turtle/#in-html
For SVG (and currently SVG only) the method also extracts an embedded RDF/XML data, per SVG specification
License: W3C Software License, http://www.w3.org/Consortium/Legal/copyright-software Author: Ivan Herman Copyright: W3C
-
class
rdflib.plugins.parsers.hturtle.
HTurtle
(options=None, base='', media_type='')[source]¶ Bases:
rdflib.plugins.parsers.pyRdfa.pyRdfa
Bastardizing the RDFa 1.1 parser to do a hturtle extractions
-
__module__
= 'rdflib.plugins.parsers.hturtle'¶
-
-
class
rdflib.plugins.parsers.hturtle.
HTurtleParser
[source]¶ Bases:
rdflib.parser.Parser
-
__module__
= 'rdflib.plugins.parsers.hturtle'¶
-
parse
(source, graph, pgraph=None, media_type='')[source]¶ @param source: one of the input sources that the RDFLib package defined @type source: InputSource class instance @param graph: target graph for the triples; output graph, in RDFa spec. parlance @type graph: RDFLib Graph @keyword media_type: explicit setting of the preferred media type (a.k.a. content type) of the the RDFa source. None means the content type of the HTTP result is used, or a guess is made based on the suffix of a file @type media_type: string
-
notation3
Module¶
notation3.py - Standalone Notation3 Parser Derived from CWM, the Closed World Machine
Authors of the original suite:
- Dan Connolly <@@>
- Tim Berners-Lee <@@>
- Yosi Scharf <@@>
- Joseph M. Reagle Jr. <reagle@w3.org>
- Rich Salz <rsalz@zolera.com>
http://www.w3.org/2000/10/swap/notation3.py
Copyright 2000-2007, World Wide Web Consortium. Copyright 2001, MIT. Copyright 2001, Zolera Systems Inc.
License: W3C Software License http://www.w3.org/Consortium/Legal/copyright-software
Modified by Sean B. Palmer Copyright 2007, Sean B. Palmer.
Modified to work with rdflib by Gunnar Aastrand Grimnes Copyright 2010, Gunnar A. Grimnes
-
exception
rdflib.plugins.parsers.notation3.
BadSyntax
(uri, lines, argstr, i, why)[source]¶ Bases:
exceptions.SyntaxError
-
__module__
= 'rdflib.plugins.parsers.notation3'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
message
¶
-
-
class
rdflib.plugins.parsers.notation3.
N3Parser
[source]¶ Bases:
rdflib.plugins.parsers.notation3.TurtleParser
An RDFLib parser for Notation3
See http://www.w3.org/DesignIssues/Notation3.html
-
__module__
= 'rdflib.plugins.parsers.notation3'¶
-
-
class
rdflib.plugins.parsers.notation3.
TurtleParser
[source]¶ Bases:
rdflib.parser.Parser
An RDFLib parser for Turtle
See http://www.w3.org/TR/turtle/
-
__module__
= 'rdflib.plugins.parsers.notation3'¶
-
-
rdflib.plugins.parsers.notation3.
splitFragP
(uriref, punct=0)[source]¶ split a URI reference before the fragment
Punctuation is kept.
e.g.
>>> splitFragP("abc#def") ('abc', '#def')
>>> splitFragP("abcdef") ('abcdef', '')
-
rdflib.plugins.parsers.notation3.
join
(here, there)[source]¶ join an absolute URI and URI reference (non-ascii characters are supported/doctested; haven’t checked the details of the IRI spec though)
here
is assumed to be absolute.there
is URI reference.>>> join('http://example/x/y/z', '../abc') 'http://example/x/abc'
Raise ValueError if there uses relative path syntax but here has no hierarchical path.
>>> join('mid:foo@example', '../foo') Traceback (most recent call last): raise ValueError(here) ValueError: Base <mid:foo@example> has no slash after colon - with relative '../foo'.
>>> join('http://example/x/y/z', '') 'http://example/x/y/z'
>>> join('mid:foo@example', '#foo') 'mid:foo@example#foo'
We grok IRIs
>>> len(u'Andr\xe9') 5
>>> join('http://example.org/', u'#Andr\xe9') u'http://example.org/#Andr\xe9'
-
rdflib.plugins.parsers.notation3.
base
()[source]¶ The base URI for this process - the Web equiv of cwd
Relative or abolute unix-standard filenames parsed relative to this yeild the URI of the file. If we had a reliable way of getting a computer name, we should put it in the hostname just to prevent ambiguity
nquads
Module¶
This is a rdflib plugin for parsing NQuad files into Conjunctive graphs that can be used and queried. The store that backs the graph must be able to handle contexts.
>>> from rdflib import ConjunctiveGraph, URIRef, Namespace
>>> g = ConjunctiveGraph()
>>> data = open("test/nquads.rdflib/example.nquads", "rb")
>>> g.parse(data, format="nquads")
<Graph identifier=... (<class 'rdflib.graph.Graph'>)>
>>> assert len(g.store) == 449
>>> # There should be 16 separate contexts
>>> assert len([x for x in g.store.contexts()]) == 16
>>> # is the name of entity E10009 "Arco Publications"?
>>> # (in graph http://bibliographica.org/entity/E10009)
>>> # Looking for:
>>> # <http://bibliographica.org/entity/E10009>
>>> # <http://xmlns.com/foaf/0.1/name>
>>> # "Arco Publications"
>>> # <http://bibliographica.org/entity/E10009>
>>> s = URIRef("http://bibliographica.org/entity/E10009")
>>> FOAF = Namespace("http://xmlns.com/foaf/0.1/")
>>> assert(g.value(s, FOAF.name).eq("Arco Publications"))
nt
Module¶
-
class
rdflib.plugins.parsers.nt.
NTSink
(graph)[source]¶ Bases:
object
-
__module__
= 'rdflib.plugins.parsers.nt'¶
-
-
class
rdflib.plugins.parsers.nt.
NTParser
[source]¶ Bases:
rdflib.parser.Parser
parser for the ntriples format, often stored with the .nt extension
See http://www.w3.org/TR/rdf-testcases/#ntriples
-
__module__
= 'rdflib.plugins.parsers.nt'¶
-
ntriples
Module¶
N-Triples Parser License: GPL 2, W3C, BSD, or MIT Author: Sean B. Palmer, inamidst.com
-
class
rdflib.plugins.parsers.ntriples.
Sink
[source]¶ Bases:
object
-
__module__
= 'rdflib.plugins.parsers.ntriples'¶
-
rdfxml
Module¶
An RDF/XML parser for RDFLib
-
class
rdflib.plugins.parsers.rdfxml.
BagID
(val)[source]¶ Bases:
rdflib.term.URIRef
-
__module__
= 'rdflib.plugins.parsers.rdfxml'¶
-
__slots__
= ['li']¶
-
li
¶
-
-
class
rdflib.plugins.parsers.rdfxml.
ElementHandler
[source]¶ Bases:
object
-
__module__
= 'rdflib.plugins.parsers.rdfxml'¶
-
__slots__
= ['start', 'char', 'end', 'li', 'id', 'base', 'subject', 'predicate', 'object', 'list', 'language', 'datatype', 'declared', 'data']¶
-
base
¶
-
char
¶
-
data
¶
-
datatype
¶
-
declared
¶
-
end
¶
-
id
¶
-
language
¶
-
li
¶
-
list
¶
-
object
¶
-
predicate
¶
-
start
¶
-
subject
¶
-
structureddata
Module¶
Extraction parsers for structured data embedded into HTML or XML files. The former may include RDFa or microdata. The syntax and the extraction procedures are based on:
- The RDFa specifications: http://www.w3.org/TR/#tr_RDFa
- The microdata specification: http://www.w3.org/TR/microdata/
- The specification of the microdata to RDF conversion:
http://www.w3.org/TR/microdata-rdf/
License: W3C Software License, http://www.w3.org/Consortium/Legal/copyright-software Author: Ivan Herman Copyright: W3C
-
class
rdflib.plugins.parsers.structureddata.
MicrodataParser
[source]¶ Bases:
rdflib.parser.Parser
Wrapper around an HTML5 microdata, extracted and converted into RDF. For the specification of microdata, see the relevant section of the HTML5 spec: http://www.w3.org/TR/microdata/; for the algorithm used to extract microdata into RDF, see http://www.w3.org/TR/microdata-rdf/.
-
__module__
= 'rdflib.plugins.parsers.structureddata'¶
-
parse
(source, graph, vocab_expansion=False, vocab_cache=False)[source]¶ @param source: one of the input sources that the RDFLib package defined @type source: InputSource class instance @param graph: target graph for the triples; output graph, in RDFa spec. parlance @type graph: RDFLib Graph @keyword vocab_expansion: whether the RDFa @vocab attribute should also mean vocabulary expansion (see the RDFa 1.1 spec for further
details)@type vocab_expansion: Boolean @keyword vocab_cache: in case vocab expansion is used, whether the expansion data (i.e., vocabulary) should be cached locally. This requires the ability for the local application to write on the local file system @type vocab_chache: Boolean @keyword rdfOutput: whether Exceptions should be catched and added, as triples, to the processor graph, or whether they should be raised. @type rdfOutput: Boolean
-
-
class
rdflib.plugins.parsers.structureddata.
RDFa10Parser
[source]¶ Bases:
rdflib.parser.Parser
This is just a convenience class to wrap around the RDFa 1.0 parser.
-
__module__
= 'rdflib.plugins.parsers.structureddata'¶
-
parse
(source, graph, pgraph=None, media_type='')[source]¶ @param source: one of the input sources that the RDFLib package defined @type source: InputSource class instance @param graph: target graph for the triples; output graph, in RDFa spec. parlance @type graph: RDFLib Graph @keyword pgraph: target for error and warning triples; processor graph, in RDFa spec. parlance. If set to None, these triples are ignored @type pgraph: RDFLib Graph @keyword media_type: explicit setting of the preferred media type (a.k.a. content type) of the the RDFa source. None means the content type of the HTTP result is used, or a guess is made based on the suffix of a file @type media_type: string @keyword rdfOutput: whether Exceptions should be catched and added, as triples, to the processor graph, or whether they should be raised. @type rdfOutput: Boolean
-
-
class
rdflib.plugins.parsers.structureddata.
RDFaParser
[source]¶ Bases:
rdflib.parser.Parser
Wrapper around the RDFa 1.1 parser. For further details on the RDFa 1.1 processing, see the relevant W3C documents at http://www.w3.org/TR/#tr_RDFa. RDFa 1.1 is defined for XHTML, HTML5, SVG and, in general, for any XML language.
Note that the parser can also handle RDFa 1.0 if the extra parameter is used and/or the input source uses RDFa 1.0 specific @version or DTD-s.
-
__module__
= 'rdflib.plugins.parsers.structureddata'¶
-
parse
(source, graph, pgraph=None, media_type='', rdfa_version=None, embedded_rdf=False, space_preserve=True, vocab_expansion=False, vocab_cache=False, refresh_vocab_cache=False, vocab_cache_report=False, check_lite=False)[source]¶ @param source: one of the input sources that the RDFLib package defined @type source: InputSource class instance @param graph: target graph for the triples; output graph, in RDFa spec. parlance @type graph: RDFLib Graph @keyword pgraph: target for error and warning triples; processor graph, in RDFa spec. parlance. If set to None, these triples are ignored @type pgraph: RDFLib Graph @keyword media_type: explicit setting of the preferred media type (a.k.a. content type) of the the RDFa source. None means the content type of the HTTP result is used, or a guess is made based on the suffix of a file @type media_type: string @keyword rdfa_version: 1.0 or 1.1. If the value is “”, then, by default, 1.1 is used unless the source has explicit signals to use 1.0 (e.g., using a @version attribute, using a DTD set up for 1.0, etc) @type rdfa_version: string @keyword embedded_rdf: some formats allow embedding RDF in other formats: (X)HTML can contain turtle in a special <script> element, SVG can have RDF/XML embedded in a <metadata> element. This flag controls whether those triples should be interpreted and added to the output graph. Some languages (e.g., SVG) require this, and the flag is ignored. @type embedded_rdf: Boolean @keyword space_preserve: by default, space in the HTML source must be preserved in the generated literal; this behavior can be switched off @type space_preserve: Boolean @keyword vocab_expansion: whether the RDFa @vocab attribute should also mean vocabulary expansion (see the RDFa 1.1 spec for further details) @type vocab_expansion: Boolean @keyword vocab_cache: in case vocab expansion is used, whether the expansion data (i.e., vocabulary) should be cached locally. This requires the ability for the local application to write on the local file system @type vocab_chache: Boolean @keyword vocab_cache_report: whether the details of vocabulary file caching process should be reported in the processor graph as information (mainly useful for debug) @type vocab_cache_report: Boolean @keyword refresh_vocab_cache: whether the caching checks of vocabs should be by-passed, ie, if caches should be re-generated regardless of the stored date (important for vocab development) @type refresh_vocab_cache: Boolean @keyword check_lite: generate extra warnings in case the input source is not RDFa 1.1 check_lite @type check_lite: Boolean
-
-
class
rdflib.plugins.parsers.structureddata.
StructuredDataParser
[source]¶ Bases:
rdflib.parser.Parser
Convenience parser to extract both RDFa (including embedded Turtle) and microdata from an HTML file. It is simply a wrapper around the specific parsers.
-
__module__
= 'rdflib.plugins.parsers.structureddata'¶
-
parse
(source, graph, pgraph=None, rdfa_version='', vocab_expansion=False, vocab_cache=False, media_type='text/html')[source]¶ @param source: one of the input sources that the RDFLib package defined @type source: InputSource class instance @param graph: target graph for the triples; output graph, in RDFa spec. parlance @keyword rdfa_version: 1.0 or 1.1. If the value is “”, then, by default, 1.1 is used unless the source has explicit signals to use 1.0 (e.g., using a @version attribute, using a DTD set up for 1.0, etc) @type rdfa_version: string @type graph: RDFLib Graph @keyword pgraph: target for error and warning triples; processor graph, in RDFa spec. parlance. If set to None, these triples are ignored @type pgraph: RDFLib Graph @keyword vocab_expansion: whether the RDFa @vocab attribute should also mean vocabulary expansion (see the RDFa 1.1 spec for further
details)@type vocab_expansion: Boolean @keyword vocab_cache: in case vocab expansion is used, whether the expansion data (i.e., vocabulary) should be cached locally. This requires the ability for the local application to write on the local file system @type vocab_chache: Boolean @keyword rdfOutput: whether Exceptions should be catched and added, as triples, to the processor graph, or whether they should be raised. @type rdfOutput: Boolean
-
trix
Module¶
A TriX parser for RDFLib
-
class
rdflib.plugins.parsers.trix.
TriXHandler
(store)[source]¶ Bases:
xml.sax.handler.ContentHandler
An Sax Handler for TriX. See http://sw.nokia.com/trix/
-
__module__
= 'rdflib.plugins.parsers.trix'¶
-
-
class
rdflib.plugins.parsers.trix.
TriXParser
[source]¶ Bases:
rdflib.parser.Parser
A parser for TriX. See http://sw.nokia.com/trix/
-
__module__
= 'rdflib.plugins.parsers.trix'¶
-