-
Notifications
You must be signed in to change notification settings - Fork 314
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
AutoIriMapper chooses wrong IRIs. #755
Comments
That's peculiar, you're correct but no one has reported this issue in years. I guess in most ontologies the ontology is declared first, or the local file is mapped incorrectly and the ontology is resolvedfrom its remote IRI without users noticing. The XML parser uses the xml:base instead of the ontology IRI, but it is very common for the xml:base and the ontology IRI to be identical, or for the ontology IRI to be empty - so in general this does not show up as a defect. The functional parser matches on |
I recently had to deal with a bunch of ontologies that import each other. The IRIs were overwritten by the mutual use of prefixes, which is why the error occurred. The problem can easily be fixed for Manchester Syntax by requiring that
As far as I understand, |
As a workaround, I tried to convert the ontologies to Functional Syntax. Unfortunatly, not one of them was mapped by the protected void parseIfExtensionSupported(File file) {
String name = file.getName();
int lastIndexOf = name.lastIndexOf('.');
if (lastIndexOf < 0) {
// no extension for the file, nothing to do
return;
}
String extension = name.substring(lastIndexOf);
if (".zip".equalsIgnoreCase(extension) || ".jar".equalsIgnoreCase(extension)) {
try {
ZipIRIMapper mapper = new ZipIRIMapper(file, "jar:" + file.toURI() + "!/");
mapper.oboMappings().forEach(e -> oboFileMap.put(e.getKey(), e.getValue()));
mapper.iriMappings()
.forEach(e -> ontologyIRI2PhysicalURIMap.put(e.getKey(), e.getValue()));
} catch (IOException e) {
// if we can't parse a file, then we can't map it
LOGGER.debug("Exception reading file", e);
}
} else if (".obo".equalsIgnoreCase(extension)) {
oboFileMap.put(name, IRI.create(file));
} else if (".ofn".equalsIgnoreCase(extension)) {
parseFSSFile(file);
} else if (".omn".equalsIgnoreCase(extension)) {
parseManchesterSyntaxFile(file);
} else if (fileExtensions.contains(extension.toLowerCase())) {
parseFile(file);
}
} private void parseFile(File file) {
try (FileInputStream in = new FileInputStream(file);
BufferedInputStream delegate = new BufferedInputStream(in);
InputStream is = DocumentSources.wrap(delegate);) {
currentFile = file;
// Using the default expansion limit. If the ontology IRI cannot be
// found before 64000 entities are expanded, the file is too
// expensive to parse.
SAXParsers.initParserWithOWLAPIStandards(null, "64000").parse(is, this);
} catch (SAXException | IOException e) {
// if we can't parse a file, then we can't map it
LOGGER.debug("Exception reading file", e);
}
} |
|
As you're using a very recent OWLAPI version and are working with a set of ontologies that you are in control of, another workaround is available: use An example index file is: Contents
See #375 for details on the feature |
Thanks, I will try that. |
Hey there,
I am confused by the way the
AutoIriMapper
class works: According to the source code for manchester syntax, for example, the first token enclosed by<
and>
is assumed as the IRI:This seems incorrect to me, because prefixes can be defined before the ontology IRI, but in the same way. Instead of the ontology IRI, the prefix IRI is mapped to the file. The error seems to occur for RDF/XML, too. I didn't check the other formats.
Thanks for reading,
Robin Nolte
The text was updated successfully, but these errors were encountered: