我正在使用 org.semanticweb.owlapi.model.OWLOntology
编辑 JAVA
项目的本体。我需要找到一个向 owl 类添加多个标签的解决方案。
对于 OWL-API 中的任何类 c
,我可以通过 c.getIRI()
获取其标签。但如何向此类添加第二个标签?
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLDataFactory;
import org.semanticweb.owlapi.model.OWLOntologyManager;
private static void addMultipleLabel() {
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLDataFactory factory = manager.getOWLDataFactory();
IRI iri_1 = IRI.create("my_first_label");
IRI iri_2 = IRI.create("my_second_label");
OWLClass myClass = factory.getOWLClass(iri_1);
// how to assign also iri_2 to myClass
}
我发现在SKOS中,可以为一个类添加多个标签。但是,使用 SKOS:altLabel 需要我将 owl 类定义为 SKOS 概念,这给我带来了更改项目中所有使用的模型的挑战。
有什么线索吗,如何为 OWL-API 类添加多个标签?
预先感谢您的建议和帮助。
最佳答案
感谢 Ignazio,
所以我像这样更正它:
private static void addMultipleLabel() throws OWLOntologyCreationException {
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLDataFactory factory = manager.getOWLDataFactory();
OWLOntology myOnt = manager.createOntology(IRI.create("C:\\LOCAL_FOLDER_\\ontName.owl"));
IRI iri_1 = IRI.create("my_first_label");
IRI iri_2 = IRI.create("my_second_label");
OWLClass myClass = factory.getOWLClass(iri_1);
OWLAnnotationProperty labels = factory.getRDFSLabel();
OWLAnnotation pA1 = factory.getOWLAnnotation(labels, iri_1);
OWLAnnotationAssertionAxiom myAxiom1 = factory.getOWLAnnotationAssertionAxiom(myClass.getIRI(), pA1);
manager.addAxiom(myOnt, myAxiom1);
OWLAnnotation pA2 = factory.getOWLAnnotation(labels, iri_2);
OWLAnnotationAssertionAxiom myAxiom2 = factory.getOWLAnnotationAssertionAxiom(myClass.getIRI(), pA2);
manager.addAxiom(myOnt, myAxiom2);
}
关于java - 向 OWL 类添加多个标签(类似于 SKOS :altLabel),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59688272/