Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to trigger OWL validation on load #20

Closed
agarciadom opened this issue Jan 7, 2025 · 6 comments · Fixed by #29
Closed

Add option to trigger OWL validation on load #20

agarciadom opened this issue Jan 7, 2025 · 6 comments · Fixed by #29
Labels
enhancement New feature or request

Comments

@agarciadom
Copy link
Member

By default, Jena does not validate the RDF graph against the RDFS schema. We may want to add an option that triggers validation and either produces warnings or throws an exception when enabled.

@OwenR-York
Copy link
Contributor

OwenR-York commented Feb 3, 2025

Validation

The most common reasoner operation which can't be exposed through additional triples in the inference model is that of validation. Typically the ontology languages used with the semantic web allow constraints to be expressed, the validation interface is used to detect when such constraints are violated by some data set.

https://jena.apache.org/documentation/inference/#validation

For example, to check a data set and list any problems one could do something like:

Model data = RDFDataMgr.loadModel(fname);
InfModel infmodel = ModelFactory.createRDFSModel(data);
ValidityReport validity = infmodel.validate();
if (validity.isValid()) {
    System.out.println("OK");
} else {
    System.out.println("Conflicts");
    for (Iterator i = validity.getReports(); i.hasNext(); ) {
        System.out.println(" - " + i.next());
    }
}

@OwenR-York
Copy link
Contributor

OwenR-York commented Feb 3, 2025

Housekeeping RDFModel

  • Collected the property variables/methods together

RDFModel

  • Add validation property (boolean) to RDFModel -- default on (true)
  • Add accessor/mutator for the validation property
  • Add property loading process for validation

RDFModelConfigurationDialog

  • Add UI element (check box) to set the validation of models on load
  • Add validation property storing process
  • Add validation property recall process

RDFModel

  • Add validation method
  • Capture validation errors with an EolModelLoadingException
  • Insert validation method call into the load process

Test

  • Add test to the OWLDemoData that runs validation to detect issues with MaxCardinality

@OwenR-York
Copy link
Contributor

The validation of InfModel and OntModel behave differently, likely due to the reasoner in the model type objects. Validating an InfModel can report errors with maxCardinality, the same infModel added into an OntModel passes validation without flagging the maxCardinality.

@OwenR-York
Copy link
Contributor

We needed to change the call that creates the empty ontModel to which the loaded models are added. The create method is now called using a "Specification", this defines the kind of reasoner created inside the ontModel instance. Depending on the reasoner within the ontModel, validation() works differently. The InfModel created to merge the Schema and Data models had an OWLFBRuleReasoner that detected a fault in the OWL Demo Data (expected). A default OntModel does not have this kind of reasoner that is not OWL aware, and does not find the faults in the OWL Demo Data.

//Create an OntModel to handle the data model being loaded or inferred from data and schema
this.model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_RULE_INF);
/** A specification for OWL models that are stored in memory and use the OWL rules inference engine for additional entailments */
    public static final OntModelSpec OWL_MEM_RULE_INF = new OntModelSpec( ModelFactory.createMemModelMaker(), null, OWLFBRuleReasonerFactory.theInstance(), ProfileRegistry.OWL_LANG );

@OwenR-York
Copy link
Contributor

There may be the need to offer more than one type of validation in the future. There are different options within Jena, based on the type of reasoner for example. Furthermore, there are other validation tools outside of Jena that could be connected to the EMC driver offering a wider array of validation tools.

@OwenR-York
Copy link
Contributor

OwenR-York commented Feb 7, 2025

Change the internal property representation for validation to a text string, which can be used for a wider scope of validation processes.

  • Change the property handling (internally) from boolean to pure string

@OwenR-York OwenR-York linked a pull request Feb 7, 2025 that will close this issue
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants