Skip to content

Conversation

@gouttegd
Copy link
Contributor

Resolves [#1038]

  • docs/ have been added/updated
  • tests have been added/updated
  • mvn verify says all tests pass
  • mvn site says all JavaDocs correct
  • CHANGELOG.md has been updated

This PR is another attempt to implement the --input-format option requested in #1038. The difference with #1056 is that instead of restricting the parsers available to the OWLManager (which has the side effect that imports cannot be parsed if they happen to be in a different format than the main ontology), here we simply explicitly pass a OWLDocumentFormat object when constructing the OWLOntologyDocumentSource (as suggested by @balhoff here).

Add a common `--input-format` option which accepts the same values as
the `--output-format` option, but indicates the expected format of the
input file (as loaded by the `CommandLineHelper.updateInputOntology`
method).
Update the `CommandLineHelper.getInputOntologies()` methods so that they
too use the `--input-format` option if it is present in the command
line.
Mention the `--input-format` option in the global documentation.

Add a basic test in which we attempt to load a OFN-formatted file that
imports a OWL file, first with the correct format, then with an
incorrect format.
@gouttegd gouttegd self-assigned this Oct 26, 2025
@gouttegd gouttegd requested review from balhoff and matentzn October 26, 2025 21:10
Copy link
Contributor

@matentzn matentzn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks great to me, I left a few comments for the next reviewer (not for you @gouttegd). The diff is a bit suboptimal for an easy review, but i got it in the end

  1. You did not remove any method ✅
  2. Your changes are documented ✅
  3. The default behaviour appears to be preserved (based my reading of FileDocumentSource(x,y)) ✅

@balhoff can you also to a sweep?

// Otherwise load from file using default method
return loadOntology(manager, new FileDocumentSource(ontologyFile));
OWLDocumentFormat fmt = inputFormat != null ? getFormat(inputFormat) : null;
return loadOntology(manager, new FileDocumentSource(ontologyFile, fmt));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to next reviewer: I expect that FileDocumentSource(,) handles the case where fmt is null by trying to "guess" the format as usual. This is the most important assumption in this PR as it basically ensures that the old functionality prevails when no --input-format is supplied.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Calling the FileDocumentSource constructor with a null argument for the document format is basically the same thing as calling the 1-argument constructor. In fact the 1-argument constructor does nothing else but calling another constructor with a null argument for the format.

Copy link
Contributor

@balhoff balhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @gouttegd! I approve, but check my one code comment.

@jamesaoverton jamesaoverton merged commit 73c2ba3 into ontodev:master Oct 30, 2025
3 checks passed
@jamesaoverton
Copy link
Member

Much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants