获取.Net中本体类的个体

发布于 2024-07-26 07:44:57 字数 2736 浏览 6 评论 0原文

关于我的上一篇文章, 现在,当我测试时,下面的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沧笙踏歌 2024-08-02 07:44:57

您得到的字段为零,因为您的 Program 类不是枚举的 OWL 类

根本问题是你的本体表达了程序不是什么,而不是说它是什么。 这并没有错,只是不是你想要的。 我是一个人,我可以弄清楚你想要什么(即你有 4 个且只有 4 个程序,而且它们都是不同的),但是你的本体论并没有这么说。 你的本体说的是这样的:

  • 有程序。
  • 如果一个人恰好是一个程序,那么它肯定不是学生、教师等。
  • 程序始终具有 atGrade 属性。
  • 如果它们碰巧是 IT、软件、管理或文学,那么它们就不一样。

但你可以有很多其他人,不仅仅是 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:

  • There are Programs.
  • If an individual happens to be a Program then it is surely not Student, Teacher, etc.
  • Programs always have atGrade property.
  • If they happen to be either IT, SW, Mgmt, or Literature, they are not the same.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文