[英]Ontology design about creating subclasses with static object values
I have a question related to an ontology design.我有一个与本体设计有关的问题。 Assume that I have a Test-Student relation.
假设我有一个应试学生关系。 Student can have one or more English tests (different types).
学生可以参加一项或多项英语测试(不同类型)。 I am writing the data point of view here so first I created the following triples (not everything might make sense, the numbers,types etc are representative).
我在这里写数据观点,所以首先我创建了以下三元组(并非所有内容都有意义,数字、类型等具有代表性)。 But test range and test style are always going to be the same for the student.
但是对于学生来说,测试范围和测试方式总是相同的。
<http://example.org/student1_english_test>
a <http://example.org/EnglishTest> ;
<http://example.org/testResult>
"80"^^<http://www.w3.org/2001/XMLSchema#double> ;
<http://example.org/testType>
<http://example.org/test/TOEFL_test> ;
<http://example.org/testRange>
<http://example.org/1-100> ;
<http://example.org/testStyle>
<http://example.org/Facultative> .
However, I noticed that test range and test style were repetitive so I wanted to create TOEFL and IELTS as subclasses of English test so that I define them once with relevant properties and describe it once so that they dont repeat.然而,我注意到测试范围和测试风格是重复的,所以我想创建托福和雅思作为英语测试的子类,以便我用相关属性定义它们一次并描述一次,这样它们就不会重复。 Can I use directly like as follows?
我可以像下面这样直接使用吗? In that case how can I describe the values for the predicates test range and test style?
在那种情况下,我如何描述谓词测试范围和测试风格的值?
<http://example.org/student1_english_test>
a <http://example.org/TOEFL_test> ;
This means that if a student takes a TOEFL test then he always will be Facultative and between the range of 1-100.这意味着,如果学生参加托福考试,那么他将始终是兼任的,并且介于 1-100 之间。 However, this is where I got confused.
然而,这就是我感到困惑的地方。 If I define them as subclasses, is it possible to define some static objects for them?
如果我将它们定义为子类,是否可以为它们定义一些 static 对象? Or do I have to create them as instances?
还是我必须将它们创建为实例?
<http://example.org/student1_english_test>
a <http://example.org/EnglishTest> ;
<http://example.org/testType>
<http://example.org/TOEFL_test> ;
<http://example.org/testResult>
"80"^^<http://www.w3.org/2001/XMLSchema#double> .
<http://example.org/xxx>
a <http://example.org/test/TOEFL_test> ;
<http://example.org/testStyle>
<http://example.org/Facultative> ;
<http://example.org#testRange>
<http://example.org/1-100> .
<http://example.org/yyy>
a <http://example.org/test/IELTS_test> ;
<http://example.org/testType>
<http://example.org/Oral> ;
<http://example.org#testRange>
<http://example.org/1.0-4.0>.
In RDF you can apply a property to anything, be it an individual or a class, but the design of your ontology (and vocabulary for that matter) depends on the conveniences you want to achieve.在 RDF 中,您可以将属性应用于任何事物,无论是个人还是 class,但本体的设计(以及相关词汇)取决于您想要实现的便利性。 There are several options:
有几种选择:
You could keep the class like <TOEFL_test>
and apply specific properties to it:您可以像
<TOEFL_test>
一样保留 class 并对其应用特定属性:
<TOEFL_test> a rdfs:Class ;
<testStyle> <Facultative> ;
<testRange> <1-100> .
<IELTS_test> a rdfs:Class ;
<testStyle> <Oral> ;
<testRange> <1.0-4.0> .
This is the simplest way to define it, but it is not much convenient to use: OWL cannot be used to treat a class as an individual (or vice versa), so these properties will be essentially invisible when you use the class in any way.这是定义它的最简单的方法,但使用起来不太方便:OWL 不能用于将 class 视为个体(反之亦然),因此当您以任何方式使用 class 时,这些属性将基本上不可见. What works however is using SPARQL, since you can write easily
?test a/<testStyle>?style
to obtain the style without having to define it on the individual.然而有效的是使用 SPARQL,因为您可以轻松编写
?test a/<testStyle>?style
来获取样式,而无需在个人上定义它。
If you want to keep the existing definition of <testStyle>
and <testRange>
, you can make some specific statements about each class that adds the respective property to all individuals:如果你想保留
<testStyle>
和<testRange>
的现有定义,你可以对每个 class 做一些具体的陈述,为所有个体添加各自的属性:
<TOEFL_test> rdfs:subClassOf [
a owl:Restriction ;
owl:onProperty <testStyle> ;
owl:hasValue <Facultative>
] , [
a owl:Restriction ;
owl:onProperty <testRange> ;
owl:hasValue <1-100>
] .
<IELTS_test> rdfs:subClassOf [
a owl:Restriction ;
owl:onProperty <testStyle> ;
owl:hasValue <Oral>
] , [
a owl:Restriction ;
owl:onProperty <testRange> ;
owl:hasValue <1.0-4.0>
] .
This also lets you keep the individual test types as classes while implying information about the individual tests, but it is a bit complex and requires you to specify this each time you add a new test type.这也允许您将各个测试类型保留为类,同时暗示有关各个测试的信息,但它有点复杂,并且需要您在每次添加新测试类型时指定这一点。
Perhaps the best way is not to use classes at all and return to individual test types:也许最好的方法是根本不使用类并返回到单独的测试类型:
<TOEFL_test>
<testStyle> <Facultative> ;
<testRange> <1-100> .
<IELTS_test>
<testStyle> <Oral> ;
<testRange> <1.0-4.0> .
<student1_english_test>
<testType> <TOEFL_test> .
You could still entail <testStyle>
and <testRange>
triples for each individual test via a property chain axiom:您仍然可以通过属性链公理为每个单独的测试提供
<testStyle>
和<testRange>
三元组:
<testStyle> owl:propertyChainAxiom ( <testType> <testStyle> ) .
<testRange> owl:propertyChainAxiom ( <testType> <testRange> ) .
You don't have to write anything complicated for each test type and the relevant information can be obtained easily through both OWL and SPARQL.您不必为每种测试类型编写任何复杂的东西,并且可以通过 OWL 和 SPARQL 轻松获得相关信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.