ntriples
N-Triples Parser License: GPL 2, W3C, BSD, or MIT Author: Sean B. Palmer, inamidst.com
Classes:
-
DummySink– -
NTGraphSink– -
NTParser–Parser for the N-Triples format, often stored with the .nt extension.
-
W3CNTriplesParser–An N-Triples Parser.
Functions:
__all__
module-attribute
r_nodeid
module-attribute
NTGraphSink
NTGraphSink(graph: Graph)
NTParser
Bases: Parser
Parser for the N-Triples format, often stored with the .nt extension.
See http://www.w3.org/TR/rdf-testcases/#ntriples
Methods:
-
parse–Parse the NT format.
Attributes:
parse
classmethod
parse(source: InputSource, sink: Graph, **kwargs: Any) -> None
Parse the NT format.
Parameters:
-
(sourceInputSource) –The source of NT-formatted data
-
(sinkGraph) –Where to send parsed triples
-
(**kwargsAny, default:{}) –Additional arguments to pass to
W3CNTriplesParser.parse
Source code in rdflib/plugins/parsers/ntriples.py
W3CNTriplesParser
W3CNTriplesParser(sink: Optional[Union[DummySink, NTGraphSink]] = None, bnode_context: Optional[_BNodeContextType] = None)
An N-Triples Parser.
This is a legacy-style Triples parser for NTriples provided by W3C
To define a context in which blank node identifiers refer to the same blank node
across instances of NTriplesParser, pass the same dict as bnode_context to each
instance. By default, a new blank node context is created for each instance of
W3CNTriplesParser.
Methods:
-
eat– -
literal– -
nodeid– -
object– -
parse–Parse f as an N-Triples file.
-
parseline– -
parsestring–Parse s as an N-Triples string.
-
peek– -
predicate– -
readline–Read an N-Triples line from buffered input.
-
subject– -
uriref–
Attributes:
-
__slots__– -
buffer(Optional[str]) – -
file(Optional[Union[TextIO, StreamReader]]) – -
line(Optional[str]) – -
sink(Union[DummySink, NTGraphSink]) – -
skolemize–
Source code in rdflib/plugins/parsers/ntriples.py
__slots__
class-attribute
instance-attribute
eat
Source code in rdflib/plugins/parsers/ntriples.py
literal
literal() -> Union[Literal[False], Literal]
Source code in rdflib/plugins/parsers/ntriples.py
nodeid
Source code in rdflib/plugins/parsers/ntriples.py
object
Source code in rdflib/plugins/parsers/ntriples.py
parse
parse(f: Union[TextIO, IO[bytes], StreamReader], bnode_context: Optional[_BNodeContextType] = None, skolemize: bool = False) -> Union[DummySink, NTGraphSink]
Parse f as an N-Triples file.
Parameters:
-
(fUnion[TextIO, IO[bytes], StreamReader]) –The N-Triples source
-
(bnode_contextOptional[_BNodeContextType], default:None) –A dict mapping blank node identifiers (e.g.,
ain_:a) toBNodeinstances. An empty dict can be passed in to define a distinct context for a given call toparse. -
(skolemizebool, default:False) –Whether to skolemize blank nodes
Returns:
-
Union[DummySink, NTGraphSink]–The sink containing the parsed triples
Source code in rdflib/plugins/parsers/ntriples.py
parseline
Source code in rdflib/plugins/parsers/ntriples.py
parsestring
Parse s as an N-Triples string.
Source code in rdflib/plugins/parsers/ntriples.py
peek
predicate
readline
Read an N-Triples line from buffered input.
Source code in rdflib/plugins/parsers/ntriples.py
subject
Source code in rdflib/plugins/parsers/ntriples.py
unquote
Unquote an N-Triples string.