@Override public OWLDocumentFormat createFormat() { return new OWLXMLDocumentFormat(); } }
@Override public OWLDocumentFormat parse(OWLOntologyDocumentSource documentSource, OWLOntology ontology, OWLOntologyLoaderConfiguration configuration) { try { OWLXMLDocumentFormat format = new OWLXMLDocumentFormat(); InputSource isrc = getInputSource(documentSource, configuration); OWLXMLPH handler = new OWLXMLPH(ontology, configuration); SAXParsers.initParserWithOWLAPIStandards(null, configuration.getEntityExpansionLimit()) .parse(isrc, handler); if (!handler.atLeastOneTagFound()) { throw new OWLXMLParserException(handler, "No known tags in the input: is the file an OWL/XML ontology?"); } format.copyPrefixesFrom(handler.getPrefixName2PrefixMap()); format.setDefaultPrefix(handler.getBase().toString()); return format; } catch (SAXException | IOException | OWLOntologyInputSourceException | IllegalStateException e) { // General exception throw new OWLParserException(e); } } }
@Override public OWLDocumentFormat parse(OWLOntologyDocumentSource documentSource, OWLOntology ontology, OWLOntologyLoaderConfiguration configuration) { try { OWLXMLDocumentFormat format = new OWLXMLDocumentFormat(); InputSource isrc = getInputSource(documentSource, configuration); OWLXMLPH handler = new OWLXMLPH(ontology, configuration); SAXParsers.initParserWithOWLAPIStandards(null, configuration.getEntityExpansionLimit()) .parse(isrc, handler); if (!handler.atLeastOneTagFound()) { throw new OWLXMLParserException(handler, "No known tags in the input: is the file an OWL/XML ontology?"); } format.copyPrefixesFrom(handler.getPrefixName2PrefixMap()); format.setDefaultPrefix(handler.getBase().toString()); return format; } catch (SAXException | IOException | OWLOntologyInputSourceException | IllegalStateException e) { // General exception throw new OWLParserException(e); } } }
@Override public OWLDocumentFormat createFormat() { return new OWLXMLDocumentFormat(); } }
@Override public OWLDocumentFormat parse(OWLOntologyDocumentSource documentSource, OWLOntology ontology, OWLOntologyLoaderConfiguration configuration) { try { OWLXMLDocumentFormat format = new OWLXMLDocumentFormat(); InputSource isrc = getInputSource(documentSource, configuration); OWLXMLPH handler = new OWLXMLPH(ontology, configuration); SAXParsers.initParserWithOWLAPIStandards(null, configuration.getEntityExpansionLimit()) .parse(isrc, handler); if (!handler.atLeastOneTagFound()) { throw new OWLXMLParserException(handler, "No known tags in the input: is the file an OWL/XML ontology?"); } format.copyPrefixesFrom(handler.getPrefixName2PrefixMap()); format.setDefaultPrefix(handler.getBase().toString()); return format; } catch (SAXException | IOException | OWLOntologyInputSourceException | IllegalStateException e) { // General exception throw new OWLParserException(e); } } }
@Override public OWLDocumentFormat createFormat() { return new OWLXMLDocumentFormat(); } }
@Override public OWLDocumentFormat parse(OWLOntologyDocumentSource documentSource, OWLOntology ontology, OWLOntologyLoaderConfiguration configuration) { try { OWLXMLDocumentFormat format = new OWLXMLDocumentFormat(); InputSource isrc = getInputSource(documentSource, configuration); OWLXMLPH handler = new OWLXMLPH(ontology, configuration); SAXParsers.initParserWithOWLAPIStandards(null, configuration.getEntityExpansionLimit()) .parse(isrc, handler); if (!handler.atLeastOneTagFound()) { throw new OWLXMLParserException(handler, "No known tags in the input: is the file an OWL/XML ontology?"); } format.copyPrefixesFrom(handler.getPrefixName2PrefixMap()); format.setDefaultPrefix(handler.getBase().toString()); return format; } catch (SAXException | IOException | OWLOntologyInputSourceException | IllegalStateException e) { // General exception throw new OWLParserException(e); } } }
public OntologyFormatPanel() { List<OWLDocumentFormat> formats = new ArrayList<>(); formats.add(new RDFXMLDocumentFormat()); formats.add(new TurtleDocumentFormat()); formats.add(new OWLXMLDocumentFormat()); formats.add(new FunctionalSyntaxDocumentFormat()); formats.add(new ManchesterSyntaxDocumentFormat()); formats.add(new OBODocumentFormat()); formats.add(new LatexDocumentFormat()); formats.add(new RDFJsonLDDocumentFormat()); formatComboBox = new JComboBox<>(formats.toArray(new OWLDocumentFormat [formats.size()])); setLayout(new BorderLayout(12, 12)); add(formatComboBox, BorderLayout.SOUTH); formatComboBox.setSelectedItem(formats.get(0)); }
public static void saveOntology(OWLOntology resultOntology, String outputFile, String outFormat) throws OWLOntologyStorageException { OWLDocumentFormat formatter; switch (outFormat) { case "OWLXML": formatter = new OWLXMLDocumentFormat(); break; case "OWLFUNCTIONAL": formatter = new FunctionalSyntaxDocumentFormat(); break; default: formatter = new OWLXMLDocumentFormat(); break; } resultOntology.getOWLOntologyManager().saveOntology(resultOntology, formatter, IRI.create(new File(outputFile))); }
public OntologyFormatPanel() { List<OWLDocumentFormat> formats = new ArrayList<>(); formats.add(new RDFXMLDocumentFormat()); formats.add(new TurtleDocumentFormat()); formats.add(new OWLXMLDocumentFormat()); formats.add(new FunctionalSyntaxDocumentFormat()); formats.add(new ManchesterSyntaxDocumentFormat()); formats.add(new OBODocumentFormat()); formats.add(new LatexDocumentFormat()); formats.add(new RDFJsonLDDocumentFormat()); formatComboBox = new JComboBox<>(formats.toArray(new OWLDocumentFormat [formats.size()])); setLayout(new BorderLayout(12, 12)); add(formatComboBox, BorderLayout.SOUTH); formatComboBox.setSelectedItem(formats.get(0)); }
/** * Saves the axioms from the ModuleExtractor in the form of an ontology containing these axioms. * * @param axioms the axioms to be saved * @param outputStream the output stream where the axioms should be saved * @throws IOException if an error occurs during the save process */ public static void saveAxioms(final Collection<OWLAxiom> axioms, final OutputStream outputStream) throws IOException { try { final OWLOntology ontology = OWL.Ontology(axioms); OWL._manager.saveOntology(ontology, new OWLXMLDocumentFormat(), outputStream); outputStream.flush(); OWL._manager.removeOntology(ontology); } catch (final OWLException e) { _logger.log(Level.SEVERE, "A problem occurred during creation or saving the ontology with axioms for the ModuleExtractor", e); throw new IOException("A problem occurred during creation or saving the ontology with axioms for the ModuleExtractor"); } }
/** * Saves the axioms from the ModuleExtractor in the form of an ontology containing these axioms. * * @param axioms the axioms to be saved * @param outputStream the output stream where the axioms should be saved * @throws IOException if an error occurs during the save process */ public static void saveAxioms(final Collection<OWLAxiom> axioms, final OutputStream outputStream) throws IOException { try { final OWLOntology ontology = OWL.Ontology(axioms); OWL._manager.saveOntology(ontology, new OWLXMLDocumentFormat(), outputStream); outputStream.flush(); OWL._manager.removeOntology(ontology); } catch (final OWLException e) { _logger.log(Level.SEVERE, "A problem occurred during creation or saving the ontology with axioms for the ModuleExtractor", e); throw new IOException("A problem occurred during creation or saving the ontology with axioms for the ModuleExtractor"); } }
formats.add("Original"); formats.add(new RDFXMLDocumentFormat()); formats.add(new OWLXMLDocumentFormat()); formats.add(new FunctionalSyntaxDocumentFormat()); formatComboBox = new JComboBox<>(formats.toArray());
/** * Saves a taxonomy into a stream. * * @param ontologyManager the ontology manager * @param taxonomy the taxonomy to be saved * @param outputStream the output stream where the ontology should be saved * @throws IOException if an I/O error should occur */ public static void save(final Taxonomy<OWLClass> taxonomy, final OutputStream outputStream) throws IOException { try { final OWLOntology ontology = createTaxonomyOntology(taxonomy); OWL._manager.saveOntology(ontology, new OWLXMLDocumentFormat(), new StreamDocumentTarget(outputStream)); outputStream.flush(); OWL._manager.removeOntology(ontology); } catch (final OWLException e) { _logger.log(Level.SEVERE, "An error occured while creating an ontology for taxonomy", e); throw new IOException("An error occured while creating an ontology for taxonomy"); } }
/** * Saves a taxonomy into a stream. * * @param ontologyManager the ontology manager * @param taxonomy the taxonomy to be saved * @param outputStream the output stream where the ontology should be saved * @throws IOException if an I/O error should occur */ public static void save(final Taxonomy<OWLClass> taxonomy, final OutputStream outputStream) throws IOException { try { final OWLOntology ontology = createTaxonomyOntology(taxonomy); OWL._manager.saveOntology(ontology, new OWLXMLDocumentFormat(), new StreamDocumentTarget(outputStream)); outputStream.flush(); OWL._manager.removeOntology(ontology); } catch (final OWLException e) { _logger.log(Level.SEVERE, "An error occured while creating an ontology for taxonomy", e); throw new IOException("An error occured while creating an ontology for taxonomy"); } }
formats.add("Original"); formats.add(new RDFXMLDocumentFormat()); formats.add(new OWLXMLDocumentFormat()); formats.add(new FunctionalSyntaxDocumentFormat()); formatComboBox = new JComboBox<>(formats.toArray());
public static void saveAxioms(Set<OWLAxiom> axioms, String outputFile, String outFormat) throws OWLOntologyStorageException, OWLOntologyCreationException { OWLOntologyManager man = OWLManager.createOWLOntologyManager(); OWLOntology resultOntology = man.createOntology(); man.addAxioms(resultOntology, axioms); OWLDocumentFormat formatter; switch (outFormat) { case "OWLXML": formatter = new OWLXMLDocumentFormat(); break; case "OWLFUNCTIONAL": formatter = new FunctionalSyntaxDocumentFormat(); break; default: formatter = new OWLXMLDocumentFormat(); break; } resultOntology.getOWLOntologyManager().saveOntology(resultOntology, formatter, IRI.create(new File(outputFile))); }
protected static OWLDocumentFormat getDocumentFormat(String format) throws Exception { OWLDocumentFormat ontoFormat; if(format == null){ ontoFormat = new RDFXMLDocumentFormat(); } else { switch (format) { case "rdfxml": ontoFormat = new RDFXMLDocumentFormat(); break; case "owlxml": ontoFormat = new OWLXMLDocumentFormat(); break; case "turtle": ontoFormat = new TurtleDocumentFormat(); break; case "n3": ontoFormat = new N3DocumentFormat(); break; default: throw new Exception("Unknown format: " + format); } } return ontoFormat; }
return new TurtleDocumentFormat(); case "owx": return new OWLXMLDocumentFormat(); case "omn": return new ManchesterSyntaxDocumentFormat();
/** * Stores the specified explanation to the specified output stream * @param explanation The explanation to be stored * @param os The output stream to store the explanation to * @throws IOException if there was a problem writing out the explanation */ public static void store(Explanation<OWLAxiom> explanation, OutputStream os, Supplier<OWLOntologyManager> m) throws IOException { try { OWLOntology ontology = m.get().createOntology(explanation.getAxioms()); OWLDataFactory df = ontology.getOWLOntologyManager().getOWLDataFactory(); OWLAnnotationProperty entailmentMarkerAnnotationProperty = df.getOWLAnnotationProperty(ENTAILMENT_MARKER_IRI); OWLAnnotation entailmentAnnotation = df.getOWLAnnotation(entailmentMarkerAnnotationProperty, df.getOWLLiteral(true)); OWLAxiom annotatedEntailment = explanation.getEntailment().getAnnotatedAxiom(Collections.singleton(entailmentAnnotation)); ontology.add(annotatedEntailment); BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(os); OWLXMLDocumentFormat justificationOntologyFormat = new OWLXMLDocumentFormat(); ontology.saveOntology(justificationOntologyFormat, bufferedOutputStream); bufferedOutputStream.flush(); } catch (OWLOntologyStorageException | OWLOntologyCreationException e) { throw new RuntimeException(e); } }