简体   繁体   English

如何以json-ld格式保存owl本体?

[英]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. 在上面的第四行代码中,它不接受saveOntology方法并抛出此建议。请您帮忙为什么这样做。 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) OWLOntologyManager类型的方法saveOntology(OWLOntology,OWLOntologyFormat,OutputStream)不适用于参数(OWLOntology,OWLDocumentFormat,OutputStream)

This code compiles with version 4 and version 5: 此代码使用版本4和版本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. 在类路径中,您必须具有版本3以及版本4或版本5,并且OWLOntologyManager接口声明来自版本3。请确保您的类路径中只有一个版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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