The surf.plugin.query_reader Module¶
-
class
surf.plugin.query_reader.RDFQueryReader(*args, **kwargs)[source]¶ Bases:
surf.plugin.reader.RDFReaderSuper class for SuRF Reader plugins that wrap queryable stores.
-
close()¶ Close the plugin and free any resources it may hold
-
concept(resource)¶ Return the concept URI of the following resource.
resource can be a string or a URIRef. :param resource: the given resource :type resource:
surf.resource.Resource
-
convert(query_result, *keys)[source]¶ Convert the results from the query to a multilevel dictionary.
This method is used by the
surf.resource.Resourceclass.
-
execute(query)[source]¶ Execute a query of type
surf.query.Query.
-
get(resource, attribute, direct)¶ Return the value(s) of the corresponding attribute.
Parameters: - resource (
surf.resource.Resource) – the given resource - attribute (str) – the given attribute
- direct (bool) – whether the attribute is a direct or inverse edge / property. If False then the subject of the resource is considered the object of the query.
Returns: the value(s) of the corresponding attribute
Return type: list
- resource (
-
inference¶ Toggle logical inference on / off. The property has any effect only if such functionality is supported by the underlying
surf.store.Storestore
-
instances_by_attribute(resource, attributes, direct, context)¶ Return all URIs that are instances of
resourceand have the specified attributes.If
directis False, than the subject of theresourceis considered the object of the query.
-
is_present(resource)¶ Check whether the resource is present in the underlying
surf.store.StorestoreParameters: resource ( surf.resource.Resource) – the given resource
-
load(resource, direct)¶ Fully load the resource from the underlying
surf.store.Storestore. This method returns all statements about the resource.If
directis False, then the subject of theresourceis considered the object of the queryParameters: - resource (
surf.resource.Resource) – the given resource - direct (bool) – whether the attribute is a direct or inverse edge / property. If False then the subject of the resource is considered the object of the query.
Returns: all statements about resource
Return type: dict
- resource (
-
-
surf.plugin.query_reader.query_ask(s, context)[source]¶ Construct
surf.query.Queryof type ASK.Parameters: - s – the subject
- context – the context
Returns: the query
Return type:
-
surf.plugin.query_reader.query_concept(s)[source]¶ Construct
surf.query.Querywith ?c as the unknown.Parameters: s – the subject Returns: the query Return type: surf.query.Query
-
surf.plugin.query_reader.query_p_s(c, p, direct, context)[source]¶ Construct
surf.query.Querywith ?s and ?c as unknowns.Parameters: - c – the class
- p – the predicate
- direct (bool) – whether the predicate is direct or inverse
- context – the context
Returns: the query
Return type:
-
surf.plugin.query_reader.query_s(s, direct, context)[source]¶ Construct
surf.query.Querywith ?p, ?v and ?c as unknowns.Parameters: - s – the subject
- direct (bool) – whether the predicate is direct or inverse
- context – the context
Returns: the query
Return type:
-
surf.plugin.query_reader.query_sp(s, p, direct, context)[source]¶ Construct
surf.query.Querywith ?v and ?c as unknowns.Parameters: - s – the subject
- p – the predicate
- direct (bool) – whether the predicate is direct or inverse
- context – the context
Returns: the query
Return type: