मैंने अपना हल किया सवाल। मुझे लगता है कि मेरे ऑटोलॉजी में कोई समस्या थी। इसलिए, मैंने व्यक्तियों का अनुमान लगाने के लिए एक और ऑटोलॉजी बनाई। मैंने जो ऑटोलॉजी बनाई है वह व्यक्ति के व्यक्ति और उप-वर्ग शामिल हैं: मालेपर्सन, मादास्पर्सन और विवाहित पीटरसन। और, दो ऑब्जेक्ट गुण हैं (हैस्पस, हैसबलिंग) और एक डेटा प्रकार की संपत्ति (हैसएज) है। और, मैंने 3 व्यक्तियों को बनाया। जॉन - MalePerson - hasAge (20) - hasSibling (जेन) जेन - FemalePerson - hasSibling (जॉन) - hasSpouse (बॉब) बॉब - MalePerson - hasSpouse (जेन)
और, मैं MalePerson के लिए दो प्रतिबंध लगा और मादास्पर्सन कक्षाएं MalePerson के लिए: hasSpouse अधिकतम 1 hasSpouse केवल MalePerson FemalePerson के लिए: hasSpouse अधिकतम 1 hasSpouse केवल FemalePerson
अन्त में, मैं एक परिभाषित वर्ग होने के लिए MarriedPerson बनाया है। तर्क से पहले, विवाहित पीटरसन के पास कोई व्यक्ति नहीं है। हालांकि, मॉडल का अनुमान लगाया जाना चाहिए कि जेन और बॉब विवाहित हैं। इसलिए, अंत में, विवाहित पीटरसन कक्षा में 2 व्यक्ति होना चाहिए।
जब मैंने जावा में जेना का उपयोग करके यह कोड चलाया, तो मुझे 2 अनुमानित व्यक्ति मिले।
OntModel ontModel = ModelFactory.createOntologyModel();
InputStream in = FileManager.get().open(inputFileName);
if (in == null) {
throw new IllegalArgumentException("File: " + inputFileName + " not found");
}
ontModel.read(in, "");
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
reasoner = reasoner.bindSchema(ontModel);
// Obtain standard OWL-DL spec and attach the Pellet reasoner
OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM;
ontModelSpec.setReasoner(reasoner);
// Create ontology model with reasoner support
OntModel model = ModelFactory.createOntologyModel(ontModelSpec, ontModel);
// MarriedPerson has no asserted instances
// However, if an inference engine is used, two of the three
// individuals in the example presented here will be
// recognized as MarriedPersons
//ns is the uri
OntClass marPerson = model.getOntClass(ns + "OWLClass_00000003866036241880"); // this is the uri for MarriedPerson class
ExtendedIterator married = marPerson.listInstances();
while(married.hasNext()) {
OntResource mp = (OntResource)married.next();
System.out.println(mp.getURI());
} // this code returns 2 individuals with the help of reasoner
अगर आप pizza.owl फ़ाइल (मुझे लगता है कि इसे कहीं सार्वजनिक हो) और यदि आप भी कोड आप 'reasoner' चर स्थापित करने के लिए प्रयोग किया जाता है प्रदान की के लिए सूचक शामिल यह उपयोगी होगा। – cygri
आपकी रुचि के लिए आपको बहुत अधिक साइग्री धन्यवाद। मैंने अपनी समस्या हल की और नीचे एक उदाहरण प्रदान किया। – Mikae