获取.Net中本体类的个体
关于我的上一篇文章, 现在,当我测试时,下面的 progFields:
System.Reflection.FieldInfo[] progFields = typeof(Program).GetFields();
不返回任何内容。 我关于程序的本体是这样的:
<owl:Class rdf:about="http://www.owl-ontologies.com/Ontology1243411901.owl#Program">
<rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
<owl:disjointWith rdf:resource="http://www.owl-ontologies.com/Ontology1243411901.owl#Student"/>
<owl:disjointWith rdf:resource="http://www.owl-ontologies.com/Ontology1243411901.owl#Teacher"/>
<owl:disjointWith rdf:resource="http://www.owl-ontologies.com/Ontology1243411901.owl#Rank"/>
<owl:disjointWith rdf:resource="http://www.owl-ontologies.com/Ontology1243411901.owl#Course"/>
<owl:disjointWith>
<owl:Class rdf:about="http://www.owl-ontologies.com/Ontology1243411901.owl#LearningResource"/>
</owl:disjointWith>
<owl:disjointWith rdf:resource="http://www.owl-ontologies.com/Ontology1243411901.owl#ResourceAuthor"/>
<owl:disjointWith rdf:resource="http://www.owl-ontologies.com/Ontology1243411901.owl#Note"/>
<owl:disjointWith rdf:resource="http://www.owl-ontologies.com/Ontology1243411901.owl#ClassOfCourse"/>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty>
<owl:ObjectProperty rdf:about="http://www.owl-ontologies.com/Ontology1243411901.owl#atGrade"/>
</owl:onProperty>
<owl:allValuesFrom rdf:resource="http://www.owl-ontologies.com/Ontology1243411901.owl#Grade"/>
</owl:Restriction>
</rdfs:subClassOf>
<owl:disjointWith>
<owl:Class rdf:about="http://www.owl-ontologies.com/Ontology1243411901.owl#Project"/>
</owl:disjointWith>
在文件末尾,定义了它的集合:
<owl:AllDifferent>
<owl:distinctMembers rdf:parseType="Collection">
<Program rdf:about="http://www.owl-ontologies.com/Ontology1243411901.owl#Information_Technology"/>
<Program rdf:about="http://www.owl-ontologies.com/Ontology1243411901.owl#Software"/>
<Program rdf:about="http://www.owl-ontologies.com/Ontology1243411901.owl#Management"/>
<Program rdf:about="http://www.owl-ontologies.com/Ontology1243411901.owl#Literature"/>
</owl:distinctMembers>
</owl:AllDifferent>
本体是由Protege制作的。 你能帮忙解决一下情况吗
Regarding to my previous post,
now when I'm testing, progFields in below:
System.Reflection.FieldInfo[] progFields = typeof(Program).GetFields();
returns nothing. My ontology about Program is like this:
<owl:Class rdf:about="http://www.owl-ontologies.com/Ontology1243411901.owl#Program">
<rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
<owl:disjointWith rdf:resource="http://www.owl-ontologies.com/Ontology1243411901.owl#Student"/>
<owl:disjointWith rdf:resource="http://www.owl-ontologies.com/Ontology1243411901.owl#Teacher"/>
<owl:disjointWith rdf:resource="http://www.owl-ontologies.com/Ontology1243411901.owl#Rank"/>
<owl:disjointWith rdf:resource="http://www.owl-ontologies.com/Ontology1243411901.owl#Course"/>
<owl:disjointWith>
<owl:Class rdf:about="http://www.owl-ontologies.com/Ontology1243411901.owl#LearningResource"/>
</owl:disjointWith>
<owl:disjointWith rdf:resource="http://www.owl-ontologies.com/Ontology1243411901.owl#ResourceAuthor"/>
<owl:disjointWith rdf:resource="http://www.owl-ontologies.com/Ontology1243411901.owl#Note"/>
<owl:disjointWith rdf:resource="http://www.owl-ontologies.com/Ontology1243411901.owl#ClassOfCourse"/>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty>
<owl:ObjectProperty rdf:about="http://www.owl-ontologies.com/Ontology1243411901.owl#atGrade"/>
</owl:onProperty>
<owl:allValuesFrom rdf:resource="http://www.owl-ontologies.com/Ontology1243411901.owl#Grade"/>
</owl:Restriction>
</rdfs:subClassOf>
<owl:disjointWith>
<owl:Class rdf:about="http://www.owl-ontologies.com/Ontology1243411901.owl#Project"/>
</owl:disjointWith>
and at the end of file, it's collection is defined:
<owl:AllDifferent>
<owl:distinctMembers rdf:parseType="Collection">
<Program rdf:about="http://www.owl-ontologies.com/Ontology1243411901.owl#Information_Technology"/>
<Program rdf:about="http://www.owl-ontologies.com/Ontology1243411901.owl#Software"/>
<Program rdf:about="http://www.owl-ontologies.com/Ontology1243411901.owl#Management"/>
<Program rdf:about="http://www.owl-ontologies.com/Ontology1243411901.owl#Literature"/>
</owl:distinctMembers>
</owl:AllDifferent>
The ontology has been made by Protege. Could you please help in situation
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您得到的字段为零,因为您的 Program 类不是枚举的 OWL 类。
根本问题是你的本体表达了程序不是什么,而不是说它是什么。 这并没有错,只是不是你想要的。 我是一个人,我可以弄清楚你想要什么(即你有 4 个且只有 4 个程序,而且它们都是不同的),但是你的本体论并没有这么说。 你的本体说的是这样的:
但你可以有很多其他人,不仅仅是 IT、软件、管理和文学。 因此,ROWLEX 不将 Program 类公开为枚举类。
如果您的 Program 类成为真正的枚举 OWL 类,ROWLEX 将为您生成静态字段。
You get zero fields because your Program class is not an enumerated OWL class.
Root issue is that your ontology expresses what Program is NOT, instead of saying what it IS. This is not wrong, just not what you want. I am a human, I can figure out what you wanted (namely that you have 4 and only 4 programs and they are all different), but your ontology does not say that. What your ontology says is as follows:
But you could have many other individuals, not only IT, SW, Mgmt,and Literature. Hence ROWLEX justly does not expose Program class as an enum class.
ROWLEX will generate you static fields if make your Program class a true enumerated OWL class.