如何使用Java或pellet将SWRL规则添加到本体中?

如何使用Java或pellet将SWRL规则添加到本体中?,java,owl,pellet,swrl,Java,Owl,Pellet,Swrl,我不想使用Protégé将规则添加到本体中,而是想使用Java或pellet将SWRL规则添加到本体中 例如,这是我想要导入到我的本体中的规则: <swrl:Imp rdf:about="#CoursePresentedInUniversityRule"> <swrl:head rdf:parseType="Collection"> <swrl:IndividualPropertyAtom> <

我不想使用Protégé将规则添加到本体中,而是想使用Java或pellet将SWRL规则添加到本体中

例如,这是我想要导入到我的本体中的规则:

<swrl:Imp rdf:about="#CoursePresentedInUniversityRule">
    <swrl:head rdf:parseType="Collection">  
        <swrl:IndividualPropertyAtom>
                <swrl:propertyPredicate rdf:resource="#coursePresentedInUniversity" />
                <swrl:argument1 rdf:resource="#x" />
                <swrl:argument2 rdf:resource="#z" />
        </swrl:IndividualPropertyAtom>
    </swrl:head>
    <swrl:body rdf:parseType="Collection">
        <swrl:ClassAtom>
            <swrl:classPredicate rdf:resource="#Course" />
            <swrl:argument1 rdf:resource="#x" />
        </swrl:ClassAtom>

        <swrl:IndividualPropertyAtom>
            <swrl:propertyPredicate rdf:resource="#teacherOf" />
            <swrl:argument1 rdf:resource="#y" />
            <swrl:argument2 rdf:resource="#x" />
        </swrl:IndividualPropertyAtom>
        <swrl:IndividualPropertyAtom>
            <swrl:propertyPredicate rdf:resource="#worksFor" />
            <swrl:argument1 rdf:resource="#y" />
            <swrl:argument2 rdf:resource="#z" />
        </swrl:IndividualPropertyAtom>

    </swrl:body>
</swrl:Imp>
[课程(?x),教师(?y,?x),工作(?y,?z)]=> [课程代表大学(?x,?z)]

我想将以下代码添加到本体中:

<swrl:Imp rdf:about="#CoursePresentedInUniversityRule">
    <swrl:head rdf:parseType="Collection">  
        <swrl:IndividualPropertyAtom>
                <swrl:propertyPredicate rdf:resource="#coursePresentedInUniversity" />
                <swrl:argument1 rdf:resource="#x" />
                <swrl:argument2 rdf:resource="#z" />
        </swrl:IndividualPropertyAtom>
    </swrl:head>
    <swrl:body rdf:parseType="Collection">
        <swrl:ClassAtom>
            <swrl:classPredicate rdf:resource="#Course" />
            <swrl:argument1 rdf:resource="#x" />
        </swrl:ClassAtom>

        <swrl:IndividualPropertyAtom>
            <swrl:propertyPredicate rdf:resource="#teacherOf" />
            <swrl:argument1 rdf:resource="#y" />
            <swrl:argument2 rdf:resource="#x" />
        </swrl:IndividualPropertyAtom>
        <swrl:IndividualPropertyAtom>
            <swrl:propertyPredicate rdf:resource="#worksFor" />
            <swrl:argument1 rdf:resource="#y" />
            <swrl:argument2 rdf:resource="#z" />
        </swrl:IndividualPropertyAtom>

    </swrl:body>
</swrl:Imp>

Java代码的一种方法是通过OWL API,
OWLDataFactory
类具有创建SWRL规则的方法,并且生成的规则可以添加到本体并保存,这与Protege 4和5使用的过程相同


文档可用

您好,我正在尝试添加swrl规则并使用java和owl api运行reasoner,但是,我迷路了,您能帮我举个例子吗?请启用,Ignazio