franz.openrdf.model package¶
Submodules¶
franz.openrdf.model.utils module¶
-
franz.openrdf.model.utils.
parse_term
(string_term)¶ Given a string representing a term in ntriples format, return a URI, Literal, or BNode.
Module contents¶
-
class
franz.openrdf.model.
BNode
(id=None)¶ Bases:
franz.openrdf.model.value.Resource
A blank node.
-
__init__
(id=None)¶ Create a blank node.
Parameters: id – Node identifier, if not supplied one will be generated.
-
getID
()¶ Get the identifier of this blank node.
-
getId
()¶ Get the identifier of this blank node.
-
getValue
()¶ Get the identifier of this blank node.
-
get_cmp_key
()¶ Return a key that will be used to compare and hash this object.
-
toNTriples
()¶ Return an NTriples representation of an open rdf term
-
to_json_ld
()¶ Converts to an object to be used as a JSON-LD value.
-
to_json_ld_key
()¶ Converts to a string to be used as a JSON-LD key.
-
-
class
franz.openrdf.model.
Literal
(label, datatype=None, language=None)¶ Bases:
franz.openrdf.model.value.Value
Implementation of the Literal class.
-
__init__
(label, datatype=None, language=None)¶ Initialize self. See help(type(self)) for accurate signature.
-
booleanValue
()¶ Convert to bool
-
calendarValue
()¶ calendarValue not useful for Python.
-
datatype
¶ The URI representing the datatype for this literal, if there is one
-
dateValue
()¶ Convert to date
-
datetimeValue
()¶ Convert to datetime
-
decimalValue
()¶ Convert to a decimal
-
floatValue
()¶ Convert to float
-
getDatatype
()¶ The URI representing the datatype for this literal, if there is one
-
getLabel
()¶ The label/value for this Literal
-
getLanguage
()¶ The language for this Literal
-
getValue
()¶ The label/value
-
get_cmp_key
()¶ Return a key that will be used to compare and hash this object.
-
intValue
()¶ Convert to int
-
label
¶ The label/value for this Literal
-
language
¶ The language for this Literal
-
longValue
()¶ Convert to long
-
setDatatype
(datatype)¶ Sets the datatype of the value
-
setLabel
(label)¶ Set the label for this Literal
-
setLanguage
(language)¶ Set the language for this Literal
-
timeValue
()¶ Convert to time
-
toNTriples
()¶ Return an NTriples representation for this Literal.
-
toPython
()¶ Return a Python object representation of this literal. Slightly silly implementation because we implement a conversion table and then don’t use the conversion functions.
-
to_json_ld
()¶ Converts to an object to be used as a JSON-LD value.
-
-
class
franz.openrdf.model.
Statement
(subject, predicate, object, context=None, id=None)¶ Bases:
object
Wraps a triple or a quad. Might also contain an id.
-
__init__
(subject, predicate, object, context=None, id=None)¶ Create a statement.
Each component can be either a Value object or a string in N-Triples format. Strings will be parsed lazily the first time a component is accessed. Accessors will always return Value objects.
Parameters: - subject (URI|BNode|str) – Subject component - URI, blank node or a string in N-Triples format.
- predicate (URI|str) – Predicate component. Either a URI or a string in N-Triples format.
- object (Value|str) – Subject component. Either a Value or a string in N-Triples format.
- context (URI|str) – Graph component (optional). Can be a URI or a string in N-Triples format.
- id (int|str) – Statement id (optional).
-
context
¶
-
getContext
()¶ Get the graph (the fourth, optional element of the statement).
Returns: Graph URI. Return type: URI
-
getPredicate
()¶ Get the predicate (the second element of the statement).
Returns: Predicate. Return type: URI
-
getSubject
()¶ Get the subject (the first element of the statement).
Returns: Subject. Return type: Value
-
getTripleID
()¶ Get the statement id.
Note that this field might not present, depending on the way in which the statement has been created.
Returns: A numerical id. Return type: int
-
id
¶
-
object
¶
-
predicate
¶
-
setContext
(context)¶
-
setObject
(object)¶
-
setPredicate
(predicate)¶
-
setSubject
(subject)¶
-
subject
¶
-
-
class
franz.openrdf.model.
URI
(uri=None, namespace=None, localname=None)¶ Bases:
franz.openrdf.model.value.Resource
Lightweight implementation of the class ‘URI’.
-
__init__
(uri=None, namespace=None, localname=None)¶ Initialize self. See help(type(self)) for accurate signature.
-
getLocalName
()¶
-
getNamespace
()¶
-
getURI
()¶ Return the URI (string) for ‘self’. This method is typically overloaded by subclasses, which may use lazy evaluation to retrieve the string.
-
getValue
()¶
-
get_cmp_key
()¶ Return a key that will be used to compare and hash this object.
-
localname
¶
-
namespace
¶
-
toNTriples
()¶ Return an NTriples representation of a resource, in this case, wrap it in angle brackets.
-
to_json_ld
()¶ Converts to an object to be used as a JSON-LD value.
-
to_json_ld_key
()¶ Converts to a string to be used as a JSON-LD key.
-
uri
¶ Return the URI (string) for ‘self’. This method is typically overloaded by subclasses, which may use lazy evaluation to retrieve the string.
-
value
¶
-
-
class
franz.openrdf.model.
Value
¶ Bases:
object
Top class in the org.openrdf.model interfaces.
-
get_cmp_key
()¶ Return a key that will be used to compare and hash this object.
-
toNTriples
()¶ Return an NTriples representation of an open rdf term
-
-
class
franz.openrdf.model.
ValueFactory
(store)¶ Bases:
object
A factory for creating URIs, blank nodes, literals and statements.
-
BLANK_NODE_AMOUNT
= 10¶
-
__init__
(store)¶ Initialize self. See help(type(self)) for accurate signature.
-
createBNode
(nodeID=None)¶
-
createLiteral
(value, datatype=None, language=None)¶
-
createRange
(lowerBound, upperBound)¶ Create a compound literal representing a range from ‘lowerBound’ to ‘upperBound’
-
createStatement
(subject, predicate, _object, context=None)¶
-
createURI
(uri=None, namespace=None, localname=None)¶
-
getUnusedBNodeId
()¶
-
namespace
(prefix)¶ Create an object that allows for simple creation of URIs in given namespace. Attribute lookups on the returned object will produce URIs with the attribute name as localname. Array item access and function calls will have the same effect.
Parameters: prefix (str) – Prefix prepended to URIs created by the returned object. Returns: An object that can be used to create URIs.
-
object_position_term_to_openrdf_term
(term, predicate=None)¶ If ‘term’ is a string, integer, float, etc, convert it to a Literal term. Otherwise, if its a Value, just pass it through.
-
validateCompoundLiteral
(term, predicate)¶ Check to see if range boundaries are mapped. TODO: ADD VALIDATION FOR GEO TERMS
-
validateRangeConstant
(term, predicate)¶ Validate an individual range constant
-
-
franz.openrdf.model.
parse_term
(string_term)¶ Given a string representing a term in ntriples format, return a URI, Literal, or BNode.