如何通过OWLAPI将rdfs:label添加到OWLIndividual? [英] How to add rdfs:label to OWLIndividual via OWLAPI?

查看:189
本文介绍了如何通过OWLAPI将rdfs:label添加到OWLIndividual?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在OWLIndividual上添加rdfs:label,我有以下内容:

I would like to add an rdfs:label to an OWLIndividual, I have the following:

OWLIndividual newIndividual = factory.getOWLNamedIndividual(IRI.create(name));
OWLLiteral lbl = factory.getOWLLiteral(name);
OWLAnnotation label =
  factory.getOWLAnnotation( 
    factory.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()), lbl);

现在,如何将标签与个人相关联?

Now, how can I associate the label to the individual?

推荐答案

您可以通过以下方式关联标签:

You can associate the label the following way:

OWLAxiom axiom = factory.getOWLAnnotationAssertionAxiom(newIndividual.asOWLNamedIndividual().getIRI(), label);
manager.applyChange(new AddAxiom(ontology, axiom));

在这种情况下,您需要使用NamedIndividual来检索IRI来声明注释.

In this case you need to work with a NamedIndividual in order to retrieve the IRI to assert the annotation.

这篇关于如何通过OWLAPI将rdfs:label添加到OWLIndividual?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆