简体   繁体   中英

How to save owl ontology in json-ld format?

OWLDocumentFormat ontologyFormat = new RDFJsonLDDocumentFormat();
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology ontology = manager.loadOntologyFromOntologyDocument(inputstream);
manager.saveOntology( ontology, ontologyFormat, outputstream );

In reference to the above code for 4th lines of code it is not accepting the saveOntology method and throwing this suggestion.Can you please help why is it doing so. You have used the same method in your code.

The method saveOntology(OWLOntology, OWLOntologyFormat, OutputStream) in the type OWLOntologyManager is not applicable for the arguments (OWLOntology, OWLDocumentFormat, OutputStream)

This code compiles with version 4 and version 5:

import java.io.InputStream;
import java.io.OutputStream;

import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.formats.RDFJsonLDDocumentFormat;
import org.semanticweb.owlapi.model.OWLDocumentFormat;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyManager;

public class Check {
    public static void main(String[] args) throws Exception {
        InputStream inputstream=null;
        OutputStream outputstream=null;
        OWLDocumentFormat ontologyFormat = new RDFJsonLDDocumentFormat();
        OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        OWLOntology ontology = manager.loadOntologyFromOntologyDocument(inputstream);
        manager.saveOntology( ontology, ontologyFormat, outputstream );
    }
}

In your classpath you must have version 3 as well as version 4 or version 5, and the OWLOntologyManager interface declaration is coming from version 3. Make sure you only have one version in your classpath.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM