Make -o parameter optional for explain.
@@ -102,7 +102,6 @@ public class ExplainCommand implements Command {
if (line.hasOption("max")) {
max = Integer.parseInt(line.getOptionValue("max"));
}
- File output = CommandLineHelper.getOutputFile(line);
OWLReasonerFactory reasonerFactory = CommandLineHelper.getReasonerFactory(line, true);
ManchesterOWLSyntaxInlineAxiomParser parser =
new ManchesterOWLSyntaxInlineAxiomParser(OWLManager.getOWLDataFactory(), checker);
@@ -112,6 +111,8 @@ public class ExplainCommand implements Command {
Set<Explanation<OWLAxiom>> explanations =
ExplainOperation.explain(axiom, ontology, reasonerFactory, max);
+ if (line.hasOption("output")) {
+ File output = CommandLineHelper.getOutputFile(line);
String result =
explanations
.stream()
@@ -123,6 +124,7 @@ public class ExplainCommand implements Command {
Writer writer = Files.newBufferedWriter(output.toPath(), StandardCharsets.UTF_8);
writer.write(result);
writer.close();
+ }
Set<OWLAxiom> explanationsAxioms =
explanations.stream().flatMap(e -> e.getAxioms().stream()).collect(Collectors.toSet());
