4

这是一个用于演示应用程序的类表达式示例:

Lecturer
and (hasResearch some (relatedTo some Semantic_Web))
and (teaches at-least 3 Course)
and (hasTitle value "Assist.Prof.")

我通过这些方法创建 OWLAPI 对象(从字符串创建 OWL 对象)。

 OWLClass lecturer = m.createOWLClassFromString("Lecturer");
 OWLObjectProperty hasResearch = m.createOWLObjectPropertyFromString("hasResearch");
 OWLObjectProperty teaches = m.createOWLObjectPropertyFromString("teaches");
 OWLNamedIndividual sWeb = m.createOWLNamedIndividualFromString("Semantic_Web");
 OWLClass course = m.createOWLClassFromString("Course");
 OWLDataProperty hasTitle = m.createOWLDataPropertyFromString("hasTitle");

如何在 Java 上实现该类表达式?

[编辑 #1] 我得到了实现:

OWLClass lecturer = m.createOWLClassFromString("Lecturer");
        OWLObjectProperty hasResearch = m.createOWLObjectPropertyFromString("hasResearch");
        OWLObjectProperty isRelatedToResearch = m.createOWLObjectPropertyFromString("isRelatedToResearch");
        OWLObjectProperty teaches = m.createOWLObjectPropertyFromString("teaches");
        OWLNamedIndividual sWeb = m.createOWLIndividualFromString("Semantic_Web");
        OWLClass course = m.createOWLClassFromString("Course");
        OWLClass researchArea = m.createOWLClassFromString("ResearchArea");
        OWLDataProperty hasTitle = m.createOWLDataPropertyFromString("hasTitle");
        OWLDatatype dt = m.getDataFactory().getRDFPlainLiteral();
        OWLLiteral asstprof = m.getDataFactory().getOWLLiteral("Asst. Prof. Dr.",dt);

        OWLClassExpression relateToSomeResearchArea = df.getOWLObjectSomeValuesFrom(isRelatedToResearch, researchArea);
        OWLClassExpression hasResearchRelateToSomeResearchArea = df.getOWLObjectSomeValuesFrom(hasResearch,relateToSomeResearchArea);
        OWLClassExpression teachesAtLeastThreeCourse = df.getOWLObjectMinCardinality(3, teaches, course);
        OWLClassExpression hasTitleAsstProf = df.getOWLDataHasValue(hasTitle, asstprof);

        Set s1 = new HashSet();
        s1.add(lecturer);
        s1.add(hasResearchRelateToSomeResearchArea);
        s1.add(teachesAtLeastThreeCourse);
        s1.add(hasTitleAsstProf);

        OWLObjectIntersectionOf iof = df.getOWLObjectIntersectionOf(s1);

        System.out.println(iof.getNestedClassExpressions());
4

0 回答 0