자꾸 까먹어서 블로그에 정리함.
RDFS Entailment 에는 모두 13개의 규칙이 존재하는데, 이 모든 규칙을 사용하여서 추론을 수행할 경우에는
간단히 Jena에서 아래와 같이 하면 됨.
ModelFactory.createRDFSModel();
그러나 간단히 subClassOf를 통한 instance의 타입 추론만 한다면 Generic을 사용하는 것이 더 효율적이라 생각함
아래와 같이
규칙 :
[rdfsRule: (?x rdf:type ?y), (?y rdfs:subClassOf ?z) (?z rdfs:subClassOf ?a) -> (?x rdf:type ?a)]
Jena:
Reasoner reasoner = new GenericRuleReasoner(Rule.rulesFromURL("resource/rules/rdfsInference.txt"));
InfModel infModel = ModelFactory.createInfModel(reasoner,model);
9.2.1 Patterns of RDFS entailment (Informative)
This section is non-normative.
RDFS entailment holds for all the following patterns, which correspond closely to the RDFS semantic conditions:
If S contains: | then S RDFS entails recognizing D: | |
---|---|---|
rdfs1 | any IRI aaa in D | aaa rdf:type rdfs:Datatype . |
rdfs2 | aaa rdfs:domain xxx . yyy aaa zzz . | yyy rdf:type xxx . |
rdfs3 | aaa rdfs:range xxx . yyy aaa zzz . | zzz rdf:type xxx . |
rdfs4a | xxx aaa yyy . | xxx rdf:type rdfs:Resource . |
rdfs4b | xxx aaa yyy. | yyy rdf:type rdfs:Resource . |
rdfs5 | xxx rdfs:subPropertyOf yyy . yyy rdfs:subPropertyOf zzz . | xxx rdfs:subPropertyOf zzz . |
rdfs6 | xxx rdf:type rdf:Property . | xxx rdfs:subPropertyOf xxx . |
rdfs7 | aaa rdfs:subPropertyOf bbb . xxx aaa yyy . | xxx bbb yyy . |
rdfs8 | xxx rdf:type rdfs:Class . | xxx rdfs:subClassOf rdfs:Resource . |
rdfs9 | xxx rdfs:subClassOf yyy . zzz rdf:type xxx . | zzz rdf:type yyy . |
rdfs10 | xxx rdf:type rdfs:Class . | xxx rdfs:subClassOf xxx . |
rdfs11 | xxx rdfs:subClassOf yyy . yyy rdfs:subClassOf zzz . | xxx rdfs:subClassOf zzz . |
rdfs12 | xxx rdf:type rdfs:ContainerMembershipProperty . | xxx rdfs:subPropertyOf rdfs:member . |
rdfs13 | xxx rdf:type rdfs:Datatype . | xxx rdfs:subClassOf rdfs:Literal . |
RDFS provides for several new ways to be unsatisfiable recognizing D. For example, the following graph is RDFS unsatisfiable recognizing {xsd:integer
, xsd:boolean
}:
ex:p rdfs:domain xsd:boolean .
ex:a rdf:type xsd:integer .
ex:a ex:p ex:c .