oldman.core.parsing.schema package

Submodules

oldman.core.parsing.schema.attribute module

class oldman.core.parsing.schema.attribute.OMAttributeExtractor(property_extractors=None, attr_md_extractors=None, use_hydra=True, use_jsonld_context=True)[source]

Bases: object

Extracts OMAttribute objects from the schema and the JSON-LD context.

Extensible in two ways:

  1. New OMPropertyExtractor objects (new RDF vocabularies);
  2. New OMAttributeMdExtractor objects (e.g. JSON-LD context);
  3. New ValueFormat objects. See its value_format_registry attribute.
Parameters:
  • property_extractors – Defaults to [].
  • attr_md_extractors – Defaults to [].
  • use_hydra – Defaults to True.
  • use_jsonld_context – Defaults to True.
add_attribute_md_extractor(attr_md_extractor)[source]

Adds a new OMAttributeMdExtractor object.

add_property_extractor(property_extractor)[source]

Adds a new OMPropertyExtractor object.

extract(class_iri, type_iris, context_js, schema_graph)[source]

Extracts metadata and generates OMProperty and OMAttribute objects.

Parameters:
  • class_iri – IRI of RDFS class of the future Model object.
  • type_iris – Ancestry of the RDFS class.
  • context_js – the JSON-LD context.
  • schema_graphrdflib.graph.Graph object.
Returns:

dict of OMAttribute objects.

value_format_registry

ValueFormatRegistry object.

class oldman.core.parsing.schema.attribute.ValueFormatRegistry(special_properties=None, include_default_datatypes=True, include_well_known_properties=True)[source]

Bases: object

Finds the ValueFormat object that corresponds to a OMAttributeMetadata object.

New ValueFormat objects can be added, for supporting:

  1. Specific properties (eg. foaf:mbox and EmailValueFormat);
  2. Other datatypes, as defined in the JSON-LD context or the RDFS domain or range (eg. xsd:string).
Parameters:
  • special_properties – Defaults to {}.
  • include_default_datatypes – Defaults to True.
  • include_well_known_properties – Defaults to True.
add_datatype(datatype_iri, value_format)[source]

Registers a ValueFormat object for a given datatype.

Parameters:
  • datatype_iri – IRI of the datatype.
  • value_formatValueFormat object.
add_special_property(property_iri, value_format)[source]

Registers a ValueFormat object for a given RDF property.

Parameters:
  • property_iri – IRI of the RDF property.
  • value_formatValueFormat object.
find_value_format(attr_md)[source]

Finds the ValueFormat object that corresponds to a OMAttributeMetadata object.

Parameters:attr_mdOMAttributeMetadata object.
Returns:ValueFormat object.

oldman.core.parsing.schema.context module

class oldman.core.parsing.schema.context.JsonLdContextAttributeMdExtractor[source]

Bases: oldman.core.parsing.schema.context.OMAttributeMdExtractor

OMAttributeMdExtractor objects that extract attribute names and datatypes from the JSON-LD context.

update(om_properties, context_js, schema_graph)[source]

See oldman.parsing.schema.context.OMAttributeMdExtractor.update().

class oldman.core.parsing.schema.context.OMAttributeMdExtractor[source]

Bases: object

An OMAttributeMdExtractor object extracts OMAttributeMetadata tuples and transmits them to OMProperty objects.

update(om_properties, context_js, schema_graph)[source]

Updates the OMProperty objects by transmitting them extracted OMAttributeMetadata tuples.

Parameters:
  • om_propertiesdict of OMProperty objects indexed by their IRIs.
  • context_js – JSON-LD context.
  • schema_graphrdflib.graph.Graph object.

oldman.core.parsing.schema.property module

class oldman.core.parsing.schema.property.HydraPropertyExtractor[source]

Bases: oldman.core.parsing.schema.property.OMPropertyExtractor

OMPropertyExtractor objects that support the Hydra vocabulary.

Currently, this class supports:
update(om_properties, class_iri, type_iris, schema_graph)[source]

See oldman.parsing.schema.property.OMPropertyExtractor.update().

class oldman.core.parsing.schema.property.OMPropertyExtractor[source]

Bases: object

An OMPropertyExtractor object generates and updates OMProperty objects from the schema RDF graph.

This class is generic and must derived for supporting various RDF vocabularies.

update(om_properties, class_iri, type_iris, schema_graph)[source]

Generates new OMProperty objects or updates them from the schema graph.

Parameters:
  • om_propertiesdict of OMProperty objects indexed by their IRIs and their reverse status.
  • class_iri – IRI of RDFS class of the future Model object.
  • type_iris – Ancestry of the RDFS class.
  • schema_graphrdflib.graph.Graph object.
Returns:

Updated dict OMProperty objects.

Module contents