Gwt 有人能告诉我如何使用protege中使用的Manchester语法提取URI标签注释的ShortformProvider吗

Gwt 有人能告诉我如何使用protege中使用的Manchester语法提取URI标签注释的ShortformProvider吗,gwt,semantics,owl,protege,Gwt,Semantics,Owl,Protege,我正在实现一个从WebProtege中使用的OWLTentity的URI中提取实体的版本。我在这方面很成功。我可以给你看下面的代码。但我现在需要从标签注释中提取。如何使用WebProtege提取它。WebProtege在创建类时不创建URI(例如)。它只有URI为的标签注释。我想从标签中提取URI。正如它所做的(例如,>“Pizza”@en>(看起来有点像这样。如果你需要正确的,我会回复。) rootOntology=getProject().getRootOntology(); System.

我正在实现一个从WebProtege中使用的OWLTentity的URI中提取实体的版本。我在这方面很成功。我可以给你看下面的代码。但我现在需要从标签注释中提取。如何使用WebProtege提取它。WebProtege在创建类时不创建URI(例如)。它只有URI为的标签注释。我想从标签中提取URI。正如它所做的(例如,>“Pizza”@en>(看起来有点像这样。如果你需要正确的,我会回复。)

rootOntology=getProject().getRootOntology();
System.out.println(rootOntology.getAxioms());
最终数据工厂数据工厂
=rootOntology.GetowOntologyManager().getOWLDataFactory();
iriShortFormProvider=新的SimpleRisShortFormProvider();
ShortFormProvider ShortFormProvider=新的ShortFormProvider(){
公共字符串getShortForm(OWLEntity OWLEntity){
返回iriShortFormProvider.getShortForm(owleEntity.getIRI());
}
@凌驾
公共空间处置(){
}
};
OWLEntityChecker entityChecker
=新ShortFormEntityChecker(
新的双向短接电源适配器(
singleton(rootOntology),shortFormProvider);
ManchesterOWLSyntaxEditorParser解析器
=新ManchesterOWLSyntaxEditorParser(
数据工厂,查询);
setowletitychecker(entityChecker);
集合;
试一试{
set=parser.parseFrames();
System.out.println(“SET SIZE”+SET.SIZE());
System.out.println(“SET字符串”+SET.toString());
用于(本体论YaxiomPair s1:set){
OWLAxiom temp=s1.getAxiom();
Set annotation=s1.getOntology().getAnnotationPropertiesInSignature();
迭代器itr=annotation.Iterator();
while(itr.hasNext()){
System.out.println(s1.getOntology().getAnnotationPropertiesInSignature());
System.out.println(“迭代器”+itr.next());
}
if(temp.getaxiotype()!=axiotype.DECLARATION
||temp.getAxiomType()!=AxiomType.SUBCLASS_OF | | temp.getAxiomType()!=AxiomType.DATA_属性_断言
)
res=搜索(临时);
}
来自WebProtege的示例:


动物型
杂食动物
食草动物
鱼
土地
动物

这就是获取标签的方式。虽然URI确实更可取,但标签也是可行的。您可以将这些标签提供给曼彻斯特语法查询。我建议您重新编写查询

OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    File file= new File("root-ontology.owl");

    OWLOntology rootOntology = manager.loadOntologyFromOntologyDocument(file);

    OWLDataFactory df  = rootOntology.getOWLOntologyManager().getOWLDataFactory();

    Set<OWLLogicalAxiom> LogicalAxiom=rootOntology.getLogicalAxioms();
    Iterator<OWLLogicalAxiom> axiom=LogicalAxiom.iterator();


        for (OWLClass cls : rootOntology.getClassesInSignature()) {

            // Get the annotations on the class that use the label property
            for (OWLAnnotation annotation : cls
                    .getAnnotations(rootOntology, df.getRDFSLabel())) {
                if (annotation.getValue() instanceof OWLLiteral) {
                    OWLLiteral val = (OWLLiteral) annotation.getValue();
                    // look for portuguese labels
                    if (val.hasLang("en"))
                        System.out.println( val.getLiteral());
                }
            }
        }
OWLOntologyManager=OWLManager.createOWLOntologyManager();
File File=新文件(“root ontology.owl”);
owlOntologRootOntology=manager.loadOntologyFromOntologyDocument(文件);
OWLDataFactory df=rootOntology.getowletologymanager().getOWLDataFactory();
Set LogicalAxiom=rootOntology.getLogicalAxiom();
迭代器公理=LogicalAxiom.Iterator();
for(OWLClass:rootOntology.getClassesInSignature()){
//获取使用label属性的类上的注释
对于(OWL注释:cls)
.getAnnotations(rootOntology,df.getRDFSLabel()){
if(注释.getValue()实例OWLLiteral){
OWLLiteral val=(OWLLiteral)annotation.getValue();
//寻找葡萄牙语标签
如果(val.hasLang(“en”))
System.out.println(val.getLiteral());
}
}
}

我是否正确理解WebProtege不允许您指定您创建的类和个人的URI?更新:我刚玩过WebProtege,看起来确实如此。这让我非常惊讶;一个不能指定URI的OWL工具不是很有用。我希望我们只是缺少了一些东西e、 @Joshua,是的,没错。我们无法获取完整的URI。