如何使用对齐API

时间:2016-08-26 13:39:01

标签: java semantic-web owl ontology apache-jena

我有一个本地alignment.rdf文件并使用对齐API库here我想创建Alignment对象并将其转换为.owl文件。

我的代码在这里:

AlignmentParser aparser = new AlignmentParser(0);
Alignment result = aparser.parse( new File( "Ontologies/alcomo-alignment.rdf" ).toURI() );
File merged1 = new File( "Ontologies/final_alignment.owl");
PrintWriter writer1 = new PrintWriter ( new FileWriter( merged1, false ), true );
AlignmentVisitor renderer1 = new OWLAxiomsRendererVisitor(writer1);
result.render(renderer1);
writer1.flush();
writer1.close();

但我面对这个错误:

OWLAxiomsRenderer: cannot render simple alignment. Need an ObjectAlignment

1 个答案:

答案 0 :(得分:0)

替换:

result.render(renderer1);

通过

ObjectAlignment oresult = ObjectAlignment.toObjectAlignment(result);
oresult.render(renderer1);

讨论:http://alignapi.gforge.inria.fr/builtin.html

请注意,为此,初始文件中的本体URI必须是可解除引用的。