Validator Interface
The Validator Interface provides access to a number of different validation operations over ontologies.
The notion of validation in OAK is intentionally very flexible, and may encompass:
Schema validation, for example, checking definitions are strings and have 0..1 cardinality.
Logical validation, using a reasoner.
Lexical validation, for example, ensuring there are no spelling errors
Stylistic validation, against a style guide
Content validation, checking the content of the ontology against domain knowledge or other ontologies.
Different adapters may implement different portions of this.
Schema Validation
The core validate method is configured using a metadata schema. The default one used is:
This is specified using LinkML which provides an expressive way to state constraints on metadata elements, such as AnnotationProperty assertions in ontologies. For example, this schema states that definition is recommended (not required), and that it is single-valued.
Different projects may wish to configure this - it is possible to pass in a different or modified schema
For more details see this howto guide
Warning
Currently only implemented for :ref`sql_implementation`
LLM-based validation
See use_llms
- class oaklib.interfaces.validator_interface.ValidatorInterface(resource: ~oaklib.resource.OntologyResource | None = None, strict: bool = False, _multilingual: bool | None = None, autosave: bool = <factory>, exclude_owl_top_and_bottom: bool = <factory>, ontology_metamodel_mapper: ~oaklib.mappers.ontology_metadata_mapper.OntologyMetadataMapper | None = None, _converter: ~curies.api.Converter | None = None, auto_relax_axioms: bool | None = None, cache_lookups: bool = False, property_cache: ~oaklib.utilities.keyval_cache.KeyValCache = <factory>, _edge_index: ~oaklib.indexes.edge_index.EdgeIndex | None = None, _entailed_edge_index: ~oaklib.indexes.edge_index.EdgeIndex | None = None, _prefix_map: ~typing.Mapping[str, str] | None = None)[source]
Multi-faceted ontology validator.
This interface defines a number of different validation processes
The overall goal is to support the following
validating against OntologyMetadata schema
lexical checks
wrapping reasoning
structural graph checks
Specific implementations may choose to implement efficient methods for this. For example, a SQL implementation can quickly determine all terms missing definitions with a query over an indexed table.
Currently the main implementation for this is the SqlDatabase implementation, this implements a generic property check using the OntologyMetadata datamodel
See:
- term_curies_without_definitions() Iterable[str] [source]
Yields all entities that do not have a definition.
- Returns:
- validate(configuration: ValidationConfiguration | None = None) Iterable[ValidationResult] [source]
Validate entire ontology or wrapped ontologies.
Validation results might be implementation specific
reasoners will yield logical problems
shape checkers or schema checkers like SHACL or LinkML will return closed-world structural violations
specialized implementations may yield lexical or other kinds of problems
- Returns:
- validate_mappings(entities: Iterable[str] | None = None, adapters: Dict[str, BasicOntologyInterface] | None = None, configuration: ValidationConfiguration | None = None) Iterable[MappingValidationResult] [source]
Validate mappings for a set of entities.
Different adapters may implement different aspects of mapping validation.
It includes:
checking cardinality of mappings (e.g. skos:exactMatch should be 1:1)
looking up mapped entities to check they are not obsolete
using AI to validate the content of mappings
- Parameters:
entities – entities to validate mappings for (None=all)
adapters – adapter mapping to look up external entities
configuration – validation configuration
- Returns:
- validate_synonyms(entities: Iterable[str] | None = None, adapters: Dict[str, BasicOntologyInterface] | None = None, configuration: ValidationConfiguration | None = None, synonymizer_rules: RuleSet | None = None) Iterable[ValidationResult] [source]
Validate synonyms for a set of entities.
Different adapters may implement different aspects of synonym validation.
It includes:
checking for duplicates
looking up mapped entities to check they are not obsolete
ensuring that a referenced synonym is still supported
using AI to validate the content of mappings
- Parameters:
entities – entities to validate mappings for (None=all)
adapters – adapter mapping to look up external entities
configuration – validation configuration
- Returns:
- validate_definitions(entities: Iterable[str] | None = None, adapters: Dict[str, BasicOntologyInterface] | None = None, configuration: ValidationConfiguration | None = None, skip_text_annotation=False, **kwargs) Iterable[ValidationResult] [source]
Validate text definitions for a set of entities.
Different adapters may implement different aspects of mapping validation.
It includes:
testing definitions are present
validating the text definition against the SRS rubric
using AI to align the definition against any references
- Parameters:
entities
configuration
kwargs
- Returns:
- repair(configuration: RepairConfiguration | None = None, dry_run=False) Iterable[RepairOperation] [source]
Finds problems and fixes them.
- Parameters:
configuration
dry_run
- Returns:
- is_coherent() bool [source]
True if the ontology is logically coherent, as determined by deductive reasoning (e.g. an OWL reasoner)
- Returns:
true if coherent
- unsatisfiable_classes(exclude_nothing=True) Iterable[str] [source]
Yields all classes that are unsatisfiable, as determined by deductive reasoning (e.g. an OWL reasoner)
- Parameters:
exclude_nothing – if True (default) do not include the tautological owl:Nothing
- Returns:
class curie iterator
- lookup_references(references: List[str], adapters: Dict[str, BasicOntologyInterface] | None = None, **kwargs) Dict[str, bool | Dict[str, Any]] [source]
Lookup references in external ontologies.
- Parameters:
references – list of CURIEs to look up
adapters – adapter mapping to look up external entities
kwargs – additional arguments
- Returns:
mapping between CURIEs and pub objects