Package ai.chatur.cortex.core.lint
Class LintService
java.lang.Object
ai.chatur.cortex.core.lint.LintService
Lints assertions against the ontology and validates them against SHACL shapes before they are
ingested.
Every property used must be declared in the ontology, and every rdf:type object must
be a class declared in the ontology. The only terms permitted beyond the ontology are
rdf:type, rdfs:label, and rdfs:comment. Assertions that pass are returned
re-serialized in Turtle syntax, ready for ingestion.
-
Constructor Summary
ConstructorsConstructorDescriptionLintService(org.apache.jena.ontapi.model.OntModel ontModel, org.apache.jena.shacl.ShaclValidator shaclValidator, org.apache.jena.shacl.Shapes shapes) Creates the service, indexing the classes and properties declared in the ontology. -
Method Summary
Modifier and TypeMethodDescriptiongetErrors(org.apache.jena.shacl.ValidationReport validationReport) Renders the violations of a validation report.ai.chatur.cortex.LintResultLints the given assertions against the ontology.org.apache.jena.shacl.ValidationReportvalidate(org.apache.jena.rdf.model.Model model) Validates the given model against the configured SHACL shapes.
-
Constructor Details
-
LintService
public LintService(org.apache.jena.ontapi.model.OntModel ontModel, org.apache.jena.shacl.ShaclValidator shaclValidator, org.apache.jena.shacl.Shapes shapes) Creates the service, indexing the classes and properties declared in the ontology.- Parameters:
ontModel- the ontology modelshaclValidator- the validator applied to incoming assertionsshapes- the SHACL shapes incoming assertions must conform to
-
-
Method Details
-
validate
public org.apache.jena.shacl.ValidationReport validate(org.apache.jena.rdf.model.Model model) Validates the given model against the configured SHACL shapes.- Parameters:
model- the model to validate- Returns:
- the validation report
-
getErrors
Renders the violations of a validation report.- Parameters:
validationReport- the report to render- Returns:
- the printed report, or
nullif the report conforms
-
lint
Lints the given assertions against the ontology.Assertions that cannot be parsed, use a property not declared in the ontology (other than
rdf:type,rdfs:label, orrdfs:comment), or type a resource with anything but an ontology class are rejected; the violations are reported in the result instead.- Parameters:
ttl- RDF assertions in Turtle syntax- Returns:
- the outcome, carrying either the validated assertions in Turtle syntax or the lint violations
-