-- 作者:byyter
-- 发布时间:4/20/2005 7:00:00 PM
-- jena求助!
jena文档中“推理支持”部分,有一个Computer的ontology的tbox文件owlDemoSchema.owl,并且有abox文件owlDemoData.rdf,我按它那么写,为什么列出的statement里面没有推理得出的信息: #########owlDemoSchema.owl##################### <?xml version="1.0"?> <!DOCTYPE rdf:RDF [ <!ENTITY eg 'urn:x-hp:eg/'> <!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'> <!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'> <!ENTITY xsd 'http://www.w3.org/2001/XMLSchema#'> <!ENTITY owl "http://www.w3.org/2002/07/owl#" > ]> <rdf:RDF xmlns:rdf="&rdf;" xmlns:rdfs="&rdfs;" xmlns:xsd="&xsd;" xmlns:owl="&owl;" xml:base="urn:x-hp:eg/" xmlns:eg="⪚" xmlns="⪚"> <owl:Class rdf:about="⪚Computer"> <rdfs:subClassOf> <rdf:Description> <owl:intersectionOf rdf:parseType="Collection"> <owl:Restriction> <owl:onProperty rdf:resource="⪚hasMotherBoard"/> <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> </owl:Restriction> </owl:intersectionOf> </rdf:Description> </rdfs:subClassOf> </owl:Class> <owl:Class rdf:about="⪚MotherBoard" /> <owl:Class rdf:about="⪚GraphicsCard" /> <owl:Class rdf:about="⪚Bundle" /> <owl:Class rdf:about="⪚GameBundle"> <rdfs:subClassOf rdf:resource="⪚Bundle" /> </owl:Class> <eg:GraphicsCard rdf:about="⪚budgetGraphics" /> <eg:GraphicsCard rdf:about="⪚gamingGraphics" /> <eg:GraphicsCard rdf:about="⪚DTPGraphics" /> <owl:ObjectProperty rdf:about="⪚hasComponent"> <rdf:type rdf:resource="&owl;TransitiveProperty" /> </owl:ObjectProperty> <owl:ObjectProperty rdf:about="⪚hasGraphics"> <rdfs:range rdf:resource="⪚GraphicsCard" /> <rdfs:subPropertyOf rdf:resource="⪚hasComponent" /> </owl:ObjectProperty> <owl:ObjectProperty rdf:about="⪚hasMotherBoard"> <rdfs:range rdf:resource="⪚MotherBoard" /> <rdfs:domain rdf:resource="⪚Computer" /> <rdfs:subPropertyOf rdf:resource="⪚hasComponent" /> </owl:ObjectProperty> <owl:ObjectProperty rdf:about="⪚hasBundle"> <rdfs:domain rdf:resource="⪚Computer" /> </owl:ObjectProperty> <owl:Class rdf:about="⪚GamingComputer"> <owl:equivalentClass> <rdf:Description> <owl:intersectionOf rdf:parseType="Collection"> <owl:Restriction> <owl:onProperty rdf:resource="⪚hasComponent" /> <owl:hasValue rdf:resource="⪚gamingGraphics" /> </owl:Restriction> <owl:Restriction> <owl:onProperty rdf:resource="⪚hasBundle" /> <owl:someValuesFrom rdf:resource="⪚GameBundle" /> </owl:Restriction> <owl:Class rdf:about="⪚Computer" /> </owl:intersectionOf> </rdf:Description> </owl:equivalentClass> </owl:Class> </rdf:RDF> ############################# #######owlDemoData.rdf############ <?xml version="1.0"?> <!DOCTYPE rdf:RDF [ <!ENTITY eg 'urn:x-hp:eg/'> <!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'> <!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'> <!ENTITY xsd 'http://www.w3.org/2001/XMLSchema#'> <!ENTITY owl "http://www.w3.org/2002/07/owl#" > ]> <rdf:RDF xmlns:rdf="&rdf;" xmlns:rdfs="&rdfs;" xmlns:xsd="&xsd;" xmlns:owl="&owl;" xml:base="urn:x-hp:eg/" xmlns="⪚"> <Computer rdf:about="⪚whiteBoxZX"> <hasMotherBoard rdf:resource="⪚nForce" /> <hasBundle> <GameBundle rdf:about="⪚actionPack" /> </hasBundle> </Computer> <Computer rdf:about="⪚whiteBoxZX"> <hasMotherBoard> <rdf:Description rdf:about="⪚unknownMB" > <hasGraphics rdf:resource="⪚gamingGraphics" /> </rdf:Description> </hasMotherBoard> </Computer> <GamingComputer rdf:about="⪚alienBox51" /> <Computer rdf:about="⪚bigName42"> <hasMotherBoard rdf:resource="⪚bigNameSpecialMB" /> <hasBundle rdf:resource="⪚binNameSpecialBundle" /> </Computer> </rdf:RDF> ######################### ##########程序代码################## Model schema = ModelLoader.loadModel("file:data/owlDemoSchema.owl"); Model data = ModelLoader.loadModel("file:data/owlDemoData.rdf"); Reasoner reasoner = ReasonerRegistry.getOWLReasoner(); reasoner = reasoner.bindSchema(schema); InfModel infmodel = ModelFactory.createInfModel(reasoner, data); Resource nForce = infmodel.getResource("urn:x-hp:eg/nForce"); System.out.println("nForce *:"); printStatements(infmodel, nForce, null, null); ############################# 文档中说运行结果是这样: nForce *: - (eg:nForce owl:sameIndividualAs eg:unknownMB) - (eg:nForce owl:sameIndividualAs eg:nForce) - (eg:nForce rdf:type owl:Thing) - (eg:nForce owl:sameAs eg:unknownMB) - (eg:nForce owl:sameAs eg:nForce) - (eg:nForce rdf:type eg:MotherBoard) - (eg:nForce rdf:type rdfs:Resource) - (eg:nForce rdf:type a3b24:f7822755ad:-7ffd) - (eg:nForce eg:hasGraphics eg:gamingGraphics) - (eg:nForce eg:hasComponent eg:gamingGraphics) 而我的运行结果一条statement也没有,我又试了”urn:x-hp:eg/whiteBoxZX“,列出的statement也都是直接信息,没有inferenced信息 哪位高人能指点一下?
|