oldman.parsing.schema package¶
Submodules¶
oldman.parsing.schema.attribute module¶
- class oldman.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:
- New OMPropertyExtractor objects (new RDF vocabularies);
- New OMAttributeMdExtractor objects (e.g. JSON-LD context);
- 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_graph – rdflib.graph.Graph object.
Returns: dict of OMAttribute objects.
- value_format_registry[source]¶
ValueFormatRegistry object.
- class oldman.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:
- Specific properties (eg. foaf:mbox and EmailValueFormat);
- 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_format – ValueFormat 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_format – ValueFormat object.
- find_value_format(attr_md)[source]¶
Finds the ValueFormat object that corresponds to a OMAttributeMetadata object.
Parameters: attr_md – OMAttributeMetadata object. Returns: ValueFormat object.
oldman.parsing.schema.context module¶
- class oldman.parsing.schema.context.JsonLdContextAttributeMdExtractor[source]¶
Bases: oldman.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.parsing.schema.context.OMAttributeMdExtractor[source]¶
Bases: object
An OMAttributeMdExtractor object extracts OMAttributeMetadata tuples and transmits them to OMProperty objects.
oldman.parsing.schema.property module¶
- class oldman.parsing.schema.property.HydraPropertyExtractor[source]¶
Bases: oldman.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.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_properties – dict 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_graph – rdflib.graph.Graph object.
Returns: Updated dict OMProperty objects.