franz.openrdf.model package

Module contents

class franz.openrdf.model.BNode(id=None)[source]

Bases: franz.openrdf.model.value.Resource

A blank node.

__init__(id=None)[source]
getID()[source]
getId()[source]
getValue()
get_cmp_key()[source]
toNTriples()[source]
class franz.openrdf.model.Literal(label, datatype=None, language=None)[source]

Bases: franz.openrdf.model.value.Value

Implementation of the Literal class.

__init__(label, datatype=None, language=None)[source]
booleanValue()[source]

Convert to bool

calendarValue()[source]

calendarValue not useful for Python.

datatype

The URI representing the datatype for this literal, if there is one

dateValue()[source]

Convert to date

datetimeValue()[source]

Convert to datetime

floatValue()[source]

Convert to float

getDatatype()[source]

The URI representing the datatype for this literal, if there is one

getLabel()[source]

The label/value for this Literal

getLanguage()[source]

The language for this Literal

getValue()[source]

The label/value

get_cmp_key()[source]
intValue()[source]

Convert to int

label

The label/value for this Literal

language

The language for this Literal

longValue()[source]

Convert to long

setDatatype(datatype)[source]

Sets the datatype of the value

setLabel(label)[source]

Set the label for this Literal

setLanguage(language)[source]

Set the language for this Literal

timeValue()[source]

Convert to time

toNTriples()[source]

Return an NTriples representation for this Literal.

toPython()[source]

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.

class franz.openrdf.model.Statement(subject, predicate, object, context=None, id=None)[source]

Bases: object

Wraps a triple or a quad. Might also contain an id.

__init__(subject, predicate, object, context=None, id=None)[source]

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 – Predicate component. Either a URI or a string in N-Triples format.

:type predicate URI|str :param object: Subject component. Either a Value or a string

in N-Triples format.
Parameters:
  • 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()[source]

Get the graph (the fourth, optional element of the statement).

Returns:Graph URI.
Return type:URI
getObject()[source]

Get the object (the third element of the statement).

Returns:Object.
Return type:Value
getPredicate()[source]

Get the predicate (the second element of the statement).

Returns:Predicate.
Return type:URI
getSubject()[source]

Get the subject (the first element of the statement).

Returns:Subject.
Return type:Value
getTripleID()[source]

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)[source]
setObject(object)[source]
setPredicate(predicate)[source]
setSubject(subject)[source]
subject
class franz.openrdf.model.URI(uri=None, namespace=None, localname=None)[source]

Bases: franz.openrdf.model.value.Resource

Lightweight implementation of the class ‘URI’.

__init__(uri=None, namespace=None, localname=None)[source]
getLocalName()[source]
getNamespace()[source]
getURI()[source]

Return the URI (string) for ‘self’. This method is typically overloaded by subclasses, which may use lazy evaluation to retrieve the string.

getValue()[source]
get_cmp_key()[source]
localname
namespace
toNTriples()[source]

Return an NTriples representation of a resource, in this case, wrap it in angle brackets.

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[source]

Bases: object

Top class in the org.openrdf.model interfaces.

get_cmp_key()[source]

Return a key that will be used to compare and hash this object.

toNTriples()[source]

Return an NTriples representation of an open rdf term

class franz.openrdf.model.ValueFactory(store)[source]

Bases: object

A factory for creating URIs, blank nodes, literals and statements.

BLANK_NODE_AMOUNT = 10
__init__(store)[source]
createBNode(nodeID=None)[source]

See RepositoryConnection.createBNode().

createLiteral(value, datatype=None, language=None)[source]

See RepositoryConnection.createLiteral().

createRange(lowerBound, upperBound)[source]

Create a compound literal representing a range from ‘lowerBound’ to ‘upperBound’

createStatement(subject, predicate, _object, context=None)[source]

See RepositoryConnection.createStatement().

createURI(uri=None, namespace=None, localname=None)[source]

See RepositoryConnection.createURI().

getUnusedBNodeId()[source]
namespace(prefix)[source]

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.

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)[source]

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)[source]

Check to see if range boundaries are mapped. TODO: ADD VALIDATION FOR GEO TERMS

validateRangeConstant(term, predicate)[source]

Validate an individual range constant

franz.openrdf.model.parse_term(string_term)[source]

Given a string representing a term in ntriples format, return a URI, Literal, or BNode.