我正在实现一个从 WebProtege 中使用的 OWLEntity 的 URI 中提取实体的版本。我在这方面很成功。我可以给你看下面的代码。但我现在需要从标签注释中提取。如何使用 WebProtege 提取它。WebProtege 在创建类时不会创建 URI(例如, http: //www.co-ode.org/ontologies/pizza/2005/05/16/pizza.owl#Pizza)。它只有带有 URI 的标签注释。我想从标签中提取 URI。正如它所拥有的那样(例如, http: //www.co-ode.org/ontologies/pizza/2005/05/16/234y2890820802840 > "Pizza"@en>。(有点像这样。如果您需要,我会回复正确的。)。
rootOntology = getProject().getRootOntology();
System.out.println(rootOntology.getAxioms());
final OWLDataFactory dataFactory
= rootOntology.getOWLOntologyManager().getOWLDataFactory();
iriShortFormProvider = new SimpleIRIShortFormProvider();
ShortFormProvider shortFormProvider = new ShortFormProvider() {
public String getShortForm(OWLEntity owlEntity) {
return iriShortFormProvider.getShortForm(owlEntity.getIRI());
}
@Override
public void dispose() {
}
};
OWLEntityChecker entityChecker
= new ShortFormEntityChecker(
new BidirectionalShortFormProviderAdapter(
Collections.singleton(rootOntology), shortFormProvider));
ManchesterOWLSyntaxEditorParser parser
= new ManchesterOWLSyntaxEditorParser(
dataFactory, query);
parser.setOWLEntityChecker(entityChecker);
Set<OntologyAxiomPair> set;
try {
set = parser.parseFrames();
System.out.println("SET SIZE" + set.size());
System.out.println("SET STRING" + set.toString());
for (OntologyAxiomPair s1 : set) {
OWLAxiom temp = s1.getAxiom();
Set<OWLAnnotationProperty> annotation = s1.getOntology().getAnnotationPropertiesInSignature();
Iterator itr = annotation.iterator();
while(itr.hasNext()){
System.out.println(s1.getOntology().getAnnotationPropertiesInSignature());
System.out.println("ITERATOR" + itr.next());
}
if (temp.getAxiomType() != AxiomType.DECLARATION
|| temp.getAxiomType() != AxiomType.SUBCLASS_OF || temp.getAxiomType() != AxiomType.DATA_PROPERTY_ASSERTION
)
res = Search(temp);
}
来自 WebProtege 的示例:
<!-- http://webprotege.stanford.edu/classes/BfJkwFDiEj5mduXojVHyKi -->
<owl:Class rdf:about="http://webprotege.stanford.edu/classes/BfJkwFDiEj5mduXojVHyKi">
<rdfs:label xml:lang="en">AnimalType</rdfs:label>
<rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
</owl:Class>
<!-- http://webprotege.stanford.edu/classes/BjSxQcpX7bOcVccVf5beN0 -->
<owl:Class rdf:about="http://webprotege.stanford.edu/classes/BjSxQcpX7bOcVccVf5beN0">
<rdfs:label xml:lang="en">Omnivore</rdfs:label>
<rdfs:subClassOf rdf:resource="http://webprotege.stanford.edu/classes/BfJkwFDiEj5mduXojVHyKi"/>
</owl:Class>
<!-- http://webprotege.stanford.edu/classes/CKjBW7KqdcJPRpBtk2T6WE -->
<owl:Class rdf:about="http://webprotege.stanford.edu/classes/CKjBW7KqdcJPRpBtk2T6WE">
<rdfs:label xml:lang="en">Herbivore</rdfs:label>
<rdfs:subClassOf rdf:resource="http://webprotege.stanford.edu/classes/BfJkwFDiEj5mduXojVHyKi"/>
</owl:Class>
<!-- http://webprotege.stanford.edu/classes/COt181AeQ0WewmOoZ0NYYF -->
<owl:Class rdf:about="http://webprotege.stanford.edu/classes/COt181AeQ0WewmOoZ0NYYF">
<rdfs:label xml:lang="en">Fish</rdfs:label>
<rdfs:subClassOf rdf:resource="http://webprotege.stanford.edu/classes/DfGxuPUoLBiOvyBKpUJWvr"/>
</owl:Class>
<!-- http://webprotege.stanford.edu/classes/CPp9DIflV676wmq3onRsJa -->
<owl:Class rdf:about="http://webprotege.stanford.edu/classes/CPp9DIflV676wmq3onRsJa">
<rdfs:label xml:lang="en">Land</rdfs:label>
<rdfs:subClassOf rdf:resource="http://webprotege.stanford.edu/classes/7V0PYXjh6vM9AjTzh9DPwC"/>
</owl:Class>
<!-- http://webprotege.stanford.edu/classes/DfGxuPUoLBiOvyBKpUJWvr -->
<owl:Class rdf:about="http://webprotege.stanford.edu/classes/DfGxuPUoLBiOvyBKpUJWvr">
<rdfs:label xml:lang="en">Animal</rdfs:label>
<rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
</owl:Class>