2013-11-23 36 views
0

你好,我想在這兩個人之間添加一個對象屬性。我也在代碼中擁有對象屬性,而個體在本體中。只需要使用屬性連接它們。個人在代碼中看起來像這樣,我的問題是我從來沒有使用這個「描述」標籤來處理這個本體。如何添加對象屬性與耶拿?特殊格式

<!-- 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給了我null值。通過名稱獲取兩個人,獲取對象屬性並將其添加到模型中。

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); 
+0

你有什麼進展嗎? –

回答

1

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"); 
1

如果你不保存你的模型在內存中,不要忘記寫出來。

final String NS = "http://vivo.iu.edu/individual/"; 
Individual doc = model.getIndividual(NS+"n6356"); 
Individual ref = model.getIndividual(NS+"n6399"); 
ObjectProperty cites = model.getObjectProperty("http://purl.org/ontology/bibo/cites"); 
model.add(doc,cites,ref).write(new FileOutputStream(new File("rdf/myRDFFile.owl"));