Class LintService

java.lang.Object
ai.chatur.cortex.core.lint.LintService

public class LintService extends Object
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

    Constructors
    Constructor
    Description
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    getErrors(org.apache.jena.shacl.ValidationReport validationReport)
    Renders the violations of a validation report.
    ai.chatur.cortex.LintResult
    lint(String ttl)
    Lints the given assertions against the ontology.
    org.apache.jena.shacl.ValidationReport
    validate(org.apache.jena.rdf.model.Model model)
    Validates the given model against the configured SHACL shapes.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 model
      shaclValidator - the validator applied to incoming assertions
      shapes - 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

      public String getErrors(org.apache.jena.shacl.ValidationReport validationReport)
      Renders the violations of a validation report.
      Parameters:
      validationReport - the report to render
      Returns:
      the printed report, or null if the report conforms
    • lint

      public ai.chatur.cortex.LintResult lint(String ttl)
      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, or rdfs: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