How to create Alignment Object using alignment API

2019-07-08 21:11发布

问题:

I have a local alignment.rdf file and using alignment API library here I want to create Alignment object and convert it to .owl file.

My code is here:

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();

but I face with this error:

OWLAxiomsRenderer: cannot render simple alignment. Need an ObjectAlignment

回答1:

Replace:

result.render(renderer1);

by

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

Discussed in: http://alignapi.gforge.inria.fr/builtin.html

Note that for this purpose, the URI of the ontologies in the initial file must be dereferenceable.