ncbo / owlapi_wrapper

A command line utility that wraps the Java OWL-API to parse RDFS, OWL and OBO ontologies.
5 stars 9 forks source link

Add IRI mapper for SKOS Core Vocabulary to prevent missing import errors #22

Closed jvendetti closed 8 months ago

jvendetti commented 8 months ago

As of recently, the W3C started rate limiting requests to http://www.w3.org/2004/02/skos/core:

We recently adjusted our abuse prevention systems to address an excessive volume of requests from automated systems, adding up to tens of millions of requests per day.

As a side effect of this, attempting to load ontologies in BioPortal that import SKOS Core, e.g.:

<owl:imports rdf:resource="http://www.w3.org/2004/02/skos/core"/>

.... result in missing import errors in the logs:

++++++++++++++++++++++++++++++++++++++++++++++++++
Error: OWL_IMPORT_MISSING
Message: http://www.w3.org/2004/02/skos/core
++++++++++++++++++++++++++++++++++++++++++++++++++

... and intermittently failing metrics-related unit tests in the ontologies_linked_data project. See this issue: https://github.com/ontoportal/ontologies_linked_data/issues/6.

Since this is an oft-imported vocabulary, I propose an initial solution of using an IRI mapper that maps to a copy of the file that we host somewhere.

jvendetti commented 8 months ago

@alexskr - any opinion on where our copy of skos.rdf should live?

alexskr commented 8 months ago

do you know if there a way to specify local file system path instead of a web address? If thats possible then embedding it with owlapi_wrapper would be my first choice. Or maybe we can host skos core in BioPortal?

Alternatively we can create a purl for it and host file on ontoportal or www.bioontology.org site.

jvendetti commented 8 months ago

The example code provided by the OWL API shows that you can use a local file system path. I tested it and it seems to work - at least in a simple unit test scenario:

@Test
public void testSimpleIRIMapper() throws Exception {
  IRI skosCoreIRI = IRI.create("http://www.w3.org/2004/02/skos/core");
  IRI skosCoreDocumentIRI = IRI.create("file:/Users/vendetti/Downloads/skos.rdf");
  SimpleIRIMapper mapper = new SimpleIRIMapper(skosCoreIRI, skosCoreDocumentIRI);

  OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
  manager.getIRIMappers().add(mapper);

  File broFile = new File("src/test/resources/BRO_v3.2.owl");
  FileDocumentSource fileDocumentSource = new FileDocumentSource(broFile);
  OWLOntology ontology = manager.loadOntologyFromOntologyDocument(fileDocumentSource);
  assertNotNull(ontology);
}

So I take it that means you'd prefer to have it embedded?

alexskr commented 8 months ago

embedding file should reduce overall complexity and improve resiliency against external resource connectivity issues.