gpt4 book ai didi

java - 如何使用 Jena 添加对象属性?特殊格式

转载 作者:行者123 更新时间:2023-12-01 23:24:49 24 4
gpt4 key购买 nike

您好,我正在尝试在这两个人之间添加一个对象属性。我在代码中也有对象属性,个体在本体中。只需要使用属性来连接它们。这些个体在代码中看起来像这样,我的问题是我从未使用此“描述”标签来处理该本体。

<!-- http://vivo.iu.edu/individual/n6356 -->

<owl:Thing rdf:about="http://vivo.iu.edu/individual/n6356">
<rdf:type rdf:resource="&bibo;Article"/>
<rdf:type rdf:resource="&bibo;Document"/>
<rdf:type rdf:resource="&vivo;ConferencePaper"/>
<rdf:type rdf:resource="&vivo;InformationResource"/>
<rdf:type rdf:resource="&owl;NamedIndividual"/>
<rdfs:label xml:lang="en-us">Indiana University Digital Music Library Project</rdfs:label>
<vitro:modTime rdf:datatype="&xsd;dateTime">2010-07-28T15:36:03</vitro:modTime>
<vitro:moniker rdf:datatype="&xsd;string">conference paper</vitro:moniker>
<bibo:doi rdf:datatype="&xsd;string">http://doi.acm.org/10.1145/379437.379774</bibo:doi>
<title>Indiana University Digital Music Library Project</title>
<dateTimeValue rdf:resource="http://vivo.iu.edu/individual/n4086167"/>
<bibo:presentedAt rdf:resource="http://vivo.iu.edu/individual/n5092"/>
<informationResourceInAuthorship rdf:resource="http://vivo.iu.edu/individual/n6257"/>
<informationResourceInAuthorship rdf:resource="http://vivo.iu.edu/individual/n6300"/>
<vitro:mostSpecificType rdf:resource="&vivo;ConferencePaper"/>
</owl:Thing>

<!-- http://vivo.iu.edu/individual/n6399 -->

<owl:Thing rdf:about="http://vivo.iu.edu/individual/n6399">
<rdf:type rdf:resource="&bibo;Article"/>
<rdf:type rdf:resource="&bibo;Document"/>
<rdf:type rdf:resource="&vivo;ConferencePaper"/>
<rdf:type rdf:resource="&vivo;InformationResource"/>
<rdf:type rdf:resource="&owl;NamedIndividual"/>
<rdfs:label xml:lang="en-us">Assessing Future Ecosystem Services: a Case Study of the Northern Highlands Lake District Wisconsin</rdfs:label>
<vitro:modTime rdf:datatype="&xsd;dateTime">2010-07-28T15:36:03</vitro:modTime>
<vitro:moniker rdf:datatype="&xsd;string">conference paper</vitro:moniker>
<bibo:doi rdf:datatype="&xsd;string">http://doi.acm.org/10.1145/379437.99999</bibo:doi>
<title>Assessing Future Ecosystem Services: a Case Study of the Northern Highlands Lake District Wisconsin</title>
<dateTimeValue rdf:resource="http://vivo.iu.edu/individual/n111111"/>
<bibo:presentedAt rdf:resource="http://vivo.iu.edu/individual/n2222"/>
<informationResourceInAuthorship rdf:resource="http://vivo.iu.edu/individual/n3333"/>
<informationResourceInAuthorship rdf:resource="http://vivo.iu.edu/individual/n4444"/>
<vitro:mostSpecificType rdf:resource="&vivo;ConferencePaper"/>
</owl:Thing>

我尝试过使用这段代码,但是 getters 给了我空值。通过名字获取两个人,获取对象属性并将它们添加到模型中。

Individual doc = model.getIndividual("n6356");
Individual ref = model.getIndividual("n6399");
ObjectProperty cites = model.getObjectProperty("http://purl.org/ontology/bibo/cites");
model.add(doc,cites,ref);

最佳答案

RDF 中的资源要么是空白节点,要么是 URI 节点。您的个人恰好是 IRI 节点,因此您需要通过以下方式检索它们:

Individual doc = model.getIndividual("http://vivo.iu.edu/individual/n6356");
Individual ref = model.getIndividual("http://vivo.iu.edu/individual/n6399");

如果您打算做很多这样的事情,那么这样做可能是有意义的:

final String NS = "http://vivo.iu.edu/individual/";
Individual doc = model.getIndividual(NS+"n6356");
Individual ref = model.getIndividual(NS+"n6399");

关于java - 如何使用 Jena 添加对象属性?特殊格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20168823/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com