Programmatically generating OWL class hierarchy with Jena

风流意气都作罢 提交于 2019-12-04 20:06:10

Your question isn't very clear (see comment, above) so I'm going to take a guess that you want to programmatically create a class hierarchy. The outline code for doing this using Jena would be:

OntModel m = ... your model ... ;
NS = "http://your.domain/example#";

// define the various classes

OntClass layer = m.createClass( NS + "Layer" );
layer.setLabel( "layer", "en" );

OntClass networkLayer = m.createClass( NS + "NetworkLayer" );
layer.setLabel( "network layer", "en" );
// ...

// create the class hierarchy

layer.addSubClass( networkLayer );
// ...

// save the file
FileWriter out = null;
try {
    out = new FileWriter( "./test.owl" );
    m.write( out, "RDF/XML-ABBREV" );
}
finally {
    if (out != null) {
        try {out.close()) ) catch (IOException ignore) {}
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!