From 29eecb27c7f91de92b21bbd646d8b7a55e526833 Mon Sep 17 00:00:00 2001 From: RncLsn Date: Tue, 16 Jun 2015 15:54:53 +0100 Subject: Maybe fixed bug in internalisation. --- data/uobm/uobm_sygenia_all-blanks.sparql | 1725 ++++++++++++++++++++ src/resources/pagoda.properties | 2 +- src/uk/ac/ox/cs/pagoda/endomorph/Endomorph.java | 10 +- .../pagoda/multistage/MultiStageQueryEngine.java | 15 - .../ox/cs/pagoda/multistage/StageQueryEngine.java | 2 - src/uk/ac/ox/cs/pagoda/query/QueryRecord.java | 4 + .../ac/ox/cs/pagoda/query/rollup/QueryGraph.java | 57 +- .../ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java | 13 +- src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java | 2 +- src/uk/ac/ox/cs/pagoda/reasoner/full/Checker.java | 2 + .../ox/cs/pagoda/reasoner/full/HermitChecker.java | 457 +++--- src/uk/ac/ox/cs/pagoda/rules/Program.java | 2 +- .../ox/cs/pagoda/summary/HermitSummaryFilter.java | 15 +- src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java | 6 +- test/resources/BugTests.xml | 17 + test/resources/Correctness.xml | 20 + test/resources/LightTests.xml | 4 +- test/resources/test.properties | 1 + .../global_tests/MinimumCardinalityTest.java | 101 ++ .../ox/cs/pagoda/global_tests/TestPagodaFLY.java | 6 +- .../ox/cs/pagoda/global_tests/TestPagodaLUBM.java | 2 +- .../ox/cs/pagoda/global_tests/TestPagodaUOBM.java | 41 +- 22 files changed, 2221 insertions(+), 283 deletions(-) create mode 100644 test/resources/BugTests.xml create mode 100644 test/resources/Correctness.xml create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/MinimumCardinalityTest.java diff --git a/data/uobm/uobm_sygenia_all-blanks.sparql b/data/uobm/uobm_sygenia_all-blanks.sparql index e69de29..3957cb8 100644 --- a/data/uobm/uobm_sygenia_all-blanks.sparql +++ b/data/uobm/uobm_sygenia_all-blanks.sparql @@ -0,0 +1,1725 @@ +^[query1] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isMemberOf ?x . + _:y rdf:type benchmark:Person +} + +^[query2] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isStudentOf ?x +} + +^[query3] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasStudent _:y . + _:z benchmark:hasStudent _:y +} + +^[query4] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:AcademicSubject +} + +^[query5] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?y benchmark:isFriendOf ?x +} + +^[query6] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasStudent _:y . + _:y benchmark:isMemberOf _:z . + _:z rdf:type benchmark:Organization +} + +^[query7] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isCrazyAbout _:y +} + +^[query8] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:SupportingStaff +} + +^[query9] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:like _:y +} + +^[query10] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:teacherOf ?x +} + +^[query11] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:ResearchGroup +} + +^[query12] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:hasMember ?x . + _:y rdf:type benchmark:ResearchGroup +} + +^[query13] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasMember _:y . + _:z benchmark:hasMember _:y . + _:z rdf:type benchmark:Organization +} + +^[query14] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isTaughtBy _:y . + _:y benchmark:isMemberOf _:z +} + +^[query15] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasUndergraduateDegreeFrom _:y +} + +^[query16] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isTaughtBy _:y . + _:y rdf:type benchmark:Person +} + +^[query17] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isMemberOf ?x . + _:y benchmark:isMemberOf _:z +} + +^[query18] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasSameHomeTownWith _:y +} + +^[query19] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?x benchmark:hasAlumnus ?y +} + +^[query20] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isTaughtBy _:y . + _:y benchmark:worksFor _:z . + _:z rdf:type benchmark:Organization +} + +^[query21] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:hasMember ?x . + _:y rdf:type benchmark:Organization +} + +^[query22] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasMember _:y . + _:y benchmark:isStudentOf _:z . + _:z rdf:type benchmark:Organization +} + +^[query23] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:hasStudent ?x . + _:y rdf:type benchmark:Organization +} + +^[query24] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:like _:y . + _:y rdf:type benchmark:Insterest +} + +^[query25] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isMemberOf ?x . + _:y benchmark:isStudentOf _:z . + _:z rdf:type benchmark:Organization +} + +^[query26] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasStudent _:y . + _:y rdf:type benchmark:Person +} + +^[query27] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isStudentOf ?x . + _:y benchmark:isMemberOf _:z . + _:z rdf:type benchmark:Organization +} + +^[query28] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:enrollIn _:y . + _:y rdf:type benchmark:Department +} + +^[query29] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:Article +} + +^[query30] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasAlumnus _:y . + _:y rdf:type benchmark:Person +} + +^[query31] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isFriendOf _:y . + _:y rdf:type benchmark:Person +} + +^[query32] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isCrazyAbout _:y . + _:y rdf:type benchmark:TennisClass +} + +^[query33] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:hasDegreeFrom ?x +} + +^[query34] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isCrazyAbout _:y . + _:y rdf:type benchmark:SwimmingClass +} + +^[query35] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:hasStudent ?x +} + +^[query36] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?y benchmark:hasAlumnus ?x +} + +^[query37] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isMemberOf ?x . + _:y benchmark:isStudentOf _:z +} + +^[query38] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isMemberOf ?x . + _:z benchmark:hasStudent _:y +} + +^[query39] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isMemberOf _:y . + _:y rdf:type benchmark:ResearchGroup +} + +^[query40] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasStudent _:y . + _:y benchmark:isStudentOf _:z . + _:z rdf:type benchmark:Organization +} + +^[query41] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasMasterDegreeFrom _:y . + _:y rdf:type benchmark:University +} + +^[query42] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:Department +} + +^[query43] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:like _:y . + _:y rdf:type benchmark:BasketBallClass +} + +^[query44] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isStudentOf ?x . + _:y benchmark:isStudentOf _:z . + _:z rdf:type benchmark:Organization +} + +^[query45] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:enrollIn _:y . + _:y rdf:type benchmark:Organization +} + +^[query46] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isMemberOf ?x . + _:y benchmark:isMemberOf _:z . + _:z rdf:type benchmark:Organization +} + +^[query47] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:Science +} + +^[query48] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasMember _:y . + _:y benchmark:isMemberOf _:z . + _:z rdf:type benchmark:Organization +} + +^[query49] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?x benchmark:like ?y +} + +^[query50] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:Sports +} + +^[query51] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:hasAlumnus ?x +} + +^[query52] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isHeadOf _:y . + _:y rdf:type benchmark:Department +} + +^[query53] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?x benchmark:teacherOf ?y +} + +^[query54] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?x benchmark:isTaughtBy ?y +} + +^[query55] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isCrazyAbout _:y . + _:y rdf:type benchmark:BasketBallClass +} + +^[query56] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isTaughtBy _:y . + _:y benchmark:isMemberOf _:z . + _:z rdf:type benchmark:Organization +} + +^[query57] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasDegreeFrom _:y +} + +^[query58] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasSameHomeTownWith _:y . + _:y rdf:type benchmark:Person +} + +^[query59] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isHeadOf _:y . + _:y rdf:type benchmark:Organization +} + +^[query60] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isMemberOf ?x . + _:z benchmark:hasMember _:y . + _:z rdf:type benchmark:Organization +} + +^[query61] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isHeadOf _:y . + _:y rdf:type benchmark:College +} + +^[query62] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasDoctoralDegreeFrom _:y . + _:y rdf:type benchmark:University +} + +^[query63] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isTaughtBy _:y . + _:z benchmark:hasMember _:y . + _:z rdf:type benchmark:Organization +} + +^[query64] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isCrazyAbout _:y . + _:y rdf:type benchmark:BaseballClass +} + +^[query65] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:like _:y . + _:y rdf:type benchmark:Sports +} + +^[query66] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:hasDegreeFrom ?x . + _:y rdf:type benchmark:Person +} + +^[query67] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?x benchmark:hasMember ?y +} + +^[query68] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:Software +} + +^[query69] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:hasSameHomeTownWith ?x +} + +^[query70] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:Professor +} + +^[query71] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:worksFor _:y . + _:y rdf:type benchmark:ResearchGroup +} + +^[query72] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isStudentOf ?x . + _:z benchmark:hasMember _:y . + _:z rdf:type benchmark:Organization +} + +^[query73] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isTaughtBy _:y . + _:y rdf:type benchmark:Employee +} + +^[query74] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:Work +} + +^[query75] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:teacherOf ?x . + _:y benchmark:worksFor _:z . + _:z rdf:type benchmark:Organization +} + +^[query76] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?x benchmark:worksFor ?y +} + +^[query77] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:TeachingAssistant +} + +^[query78] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasDegreeFrom _:y . + _:y rdf:type benchmark:University +} + +^[query79] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isCrazyAbout _:y . + _:y rdf:type benchmark:Insterest +} + +^[query80] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasStudent _:y . + _:y benchmark:isMemberOf _:z +} + +^[query81] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasStudent _:y . + _:z benchmark:hasMember _:y +} + +^[query82] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:FineArts +} + +^[query83] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isStudentOf _:y +} + +^[query84] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isFriendOf ?x . + _:y rdf:type benchmark:Person +} + +^[query85] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isFriendOf ?x +} + +^[query86] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:worksFor _:y . + _:y rdf:type benchmark:Program +} + +^[query87] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasMasterDegreeFrom _:y . + _:y rdf:type benchmark:Organization +} + +^[query88] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:Engineering +} + +^[query89] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasDoctoralDegreeFrom _:y +} + +^[query90] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasStudent _:y . + _:z benchmark:hasMember _:y . + _:z rdf:type benchmark:Organization +} + +^[query91] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:like _:y . + _:y rdf:type benchmark:BaseballClass +} + +^[query92] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:worksFor _:y +} + +^[query93] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:Faculty +} + +^[query94] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?y benchmark:hasStudent ?x +} + +^[query95] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasMajor _:y . + _:y rdf:type benchmark:Science +} + +^[query96] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:worksFor _:y . + _:y rdf:type benchmark:Department +} + +^[query97] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isFriendOf _:y +} + +^[query98] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:teacherOf ?x . + _:y benchmark:worksFor _:z +} + +^[query99] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasMember _:y . + _:y benchmark:isStudentOf _:z +} + +^[query100] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isCrazyAbout _:y . + _:y rdf:type benchmark:Sports +} + +^[query101] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isMemberOf ?x . + _:y rdf:type benchmark:Student +} + +^[query102] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:teacherOf ?x . + _:z benchmark:hasMember _:y . + _:z rdf:type benchmark:Organization +} + +^[query103] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasDoctoralDegreeFrom _:y . + _:y rdf:type benchmark:Organization +} + +^[query104] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasMember _:y . + _:y rdf:type benchmark:Student +} + +^[query105] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?y benchmark:isStudentOf ?x +} + +^[query106] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isStudentOf ?x . + _:z benchmark:hasStudent _:y +} + +^[query107] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?y benchmark:hasMember ?x +} + +^[query108] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isStudentOf ?x . + _:y rdf:type benchmark:Student +} + +^[query109] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:Course +} + +^[query110] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isHeadOf _:y . + _:y rdf:type benchmark:Program +} + +^[query111] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasStudent _:y +} + +^[query112] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:hasMember ?x . + _:y rdf:type benchmark:Program +} + +^[query113] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isMemberOf _:y . + _:y rdf:type benchmark:Organization +} + +^[query114] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:Student +} + +^[query115] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isStudentOf ?x . + _:y benchmark:isStudentOf _:z +} + +^[query116] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?x benchmark:hasStudent ?y +} + +^[query117] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasStudent _:y . + _:y rdf:type benchmark:Student +} + +^[query118] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:College +} + +^[query119] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:teacherOf _:y . + _:y rdf:type benchmark:Work +} + +^[query120] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isMemberOf _:y +} + +^[query121] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasAlumnus _:y +} + +^[query122] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:teacherOf ?x . + _:y benchmark:isMemberOf _:z +} + +^[query123] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:like _:y . + _:y rdf:type benchmark:SwimmingClass +} + +^[query124] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:hasMember ?x +} + +^[query125] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isHeadOf _:y +} + +^[query126] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasStudent _:y . + _:y benchmark:isStudentOf _:z +} + +^[query127] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isStudentOf _:y . + _:y rdf:type benchmark:Department +} + +^[query128] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:worksFor _:y . + _:y rdf:type benchmark:College +} + +^[query129] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:teacherOf _:y . + _:y rdf:type benchmark:Course +} + +^[query130] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?y benchmark:teacherOf ?x +} + +^[query131] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:Organization +} + +^[query132] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:teacherOf ?x . + _:z benchmark:hasMember _:y +} + +^[query133] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasMember _:y . + _:y rdf:type benchmark:Person +} + +^[query134] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:hasSameHomeTownWith ?x . + _:y rdf:type benchmark:Person +} + +^[query135] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isMemberOf ?x . + _:z benchmark:hasStudent _:y . + _:z rdf:type benchmark:Organization +} + +^[query136] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isMemberOf _:y . + _:y rdf:type benchmark:Program +} + +^[query137] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isStudentOf ?x . + _:y benchmark:isMemberOf _:z +} + +^[query138] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:teachingAssistantOf _:y . + _:y rdf:type benchmark:Course +} + +^[query139] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasMember _:y . + _:z benchmark:hasStudent _:y . + _:z rdf:type benchmark:Organization +} + +^[query140] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasMember _:y +} + +^[query141] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:enrollIn _:y +} + +^[query142] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isStudentOf ?x . + _:z benchmark:hasMember _:y +} + +^[query143] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?x benchmark:hasSameHomeTownWith ?y +} + +^[query144] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:hasAlumnus ?x . + _:y rdf:type benchmark:Organization +} + +^[query145] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:Dean +} + +^[query146] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isTaughtBy ?x . + _:y rdf:type benchmark:Course +} + +^[query147] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isTaughtBy _:y . + _:y rdf:type benchmark:Faculty +} + +^[query148] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isStudentOf _:y . + _:y rdf:type benchmark:Organization +} + +^[query149] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasMajor _:y . + _:y rdf:type benchmark:AcademicSubject +} + +^[query150] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?x benchmark:isStudentOf ?y +} + +^[query151] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasMember _:y . + _:z benchmark:hasStudent _:y +} + +^[query152] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasUndergraduateDegreeFrom _:y . + _:y rdf:type benchmark:University +} + +^[query153] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isStudentOf ?x . + _:z benchmark:hasStudent _:y . + _:z rdf:type benchmark:Organization +} + +^[query154] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?y benchmark:hasSameHomeTownWith ?x +} + +^[query155] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasMember _:y . + _:z benchmark:hasMember _:y +} + +^[query156] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:Employee +} + +^[query157] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:teachingAssistantOf _:y +} + +^[query158] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isTaughtBy _:y +} + +^[query159] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:Research +} + +^[query160] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?y benchmark:isMemberOf ?x +} + +^[query161] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isTaughtBy _:y . + _:z benchmark:hasMember _:y +} + +^[query162] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isTaughtBy ?x +} + +^[query163] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:teacherOf ?x . + _:y benchmark:isMemberOf _:z . + _:z rdf:type benchmark:Organization +} + +^[query164] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isMemberOf _:y . + _:y rdf:type benchmark:College +} + +^[query165] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?x benchmark:isFriendOf ?y +} + +^[query166] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?x benchmark:hasDegreeFrom ?y +} + +^[query167] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isTaughtBy ?x . + _:y rdf:type benchmark:Work +} + +^[query168] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?y benchmark:isTaughtBy ?x +} + +^[query169] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:hasAlumnus ?x . + _:y rdf:type benchmark:University +} + +^[query170] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:Person +} + +^[query171] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isTaughtBy _:y . + _:y benchmark:worksFor _:z +} + +^[query172] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasMasterDegreeFrom _:y +} + +^[query173] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isMemberOf ?x . + _:z benchmark:hasMember _:y +} + +^[query174] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:teacherOf _:y +} + +^[query175] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:isMemberOf _:y . + _:y rdf:type benchmark:Department +} + +^[query176] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?x benchmark:isMemberOf ?y +} + +^[query177] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasStudent _:y . + _:z benchmark:hasStudent _:y . + _:z rdf:type benchmark:Organization +} + +^[query178] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasMajor _:y +} + +^[query179] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:Insterest +} + +^[query180] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isStudentOf ?x . + _:y rdf:type benchmark:Person +} + +^[query181] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasDegreeFrom _:y . + _:y rdf:type benchmark:Organization +} + +^[query182] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:HumanitiesAndSocial +} + +^[query183] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:teacherOf ?x . + _:y rdf:type benchmark:Faculty +} + +^[query184] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:Publication +} + +^[query185] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:like _:y . + _:y rdf:type benchmark:TennisClass +} + +^[query186] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:isMemberOf ?x +} + +^[query187] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x ?y +WHERE { + ?y benchmark:hasDegreeFrom ?x +} + +^[query188] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasMember _:y . + _:y benchmark:isMemberOf _:z +} + +^[query189] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:teacherOf ?x . + _:y rdf:type benchmark:Person +} + +^[query190] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:teacherOf ?x . + _:y rdf:type benchmark:Employee +} + +^[query191] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:hasStudent ?x . + _:y rdf:type benchmark:Department +} + +^[query192] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:teachingAssistantOf _:y . + _:y rdf:type benchmark:Work +} + +^[query193] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:University +} + +^[query194] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:hasUndergraduateDegreeFrom _:y . + _:y rdf:type benchmark:Organization +} + +^[query195] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x rdf:type benchmark:Schedule +} + +^[query196] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + ?x benchmark:worksFor _:y . + _:y rdf:type benchmark:Organization +} + +^[query197] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:hasMember ?x . + _:y rdf:type benchmark:College +} + +^[query198] +PREFIX rdf: +PREFIX benchmark: +SELECT ?x +WHERE { + _:y benchmark:hasMember ?x . + _:y rdf:type benchmark:Department +} + diff --git a/src/resources/pagoda.properties b/src/resources/pagoda.properties index 64de225..0401d64 100644 --- a/src/resources/pagoda.properties +++ b/src/resources/pagoda.properties @@ -1,5 +1,5 @@ debug=true useAlwaysSimpleUpperBound=false -useSkolemUpperBound=true +useSkolemUpperBound=false statisticsDir=/home/alessandro/Dropbox/Oxford/PAGOdA/statistics \ No newline at end of file diff --git a/src/uk/ac/ox/cs/pagoda/endomorph/Endomorph.java b/src/uk/ac/ox/cs/pagoda/endomorph/Endomorph.java index cde0895..1c853d7 100644 --- a/src/uk/ac/ox/cs/pagoda/endomorph/Endomorph.java +++ b/src/uk/ac/ox/cs/pagoda/endomorph/Endomorph.java @@ -84,11 +84,19 @@ public class Endomorph extends Checker { return fullReasoner.isConsistent(); } + @Override + public int getNoOfCalls() { + return fullReasoner.getNoOfCalls(); + } + @Override public void dispose() { super.dispose(); - fullReasoner.dispose(); + if(fullReasoner != null) { +// Utility.logInfo("Hermit was called " + fullReasoner.getNoOfCalls() + " times"); + fullReasoner.dispose(); + } } public Graph getGraph() { diff --git a/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java b/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java index 2471c80..33f9f03 100644 --- a/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java +++ b/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java @@ -83,21 +83,6 @@ public class MultiStageQueryEngine extends StageQueryEngine { return materialise(program, treatment, gap); } - /** - * delta-chase with fixed mad term depth - */ - @Override - public int materialiseSkolemly(DatalogProgram dProgram, GapByStore4ID gap) { - if(isDisposed()) throw new DisposedException(); - - materialise("lower program", dProgram.getLower().toString()); - Program generalProgram = dProgram.getGeneral(); - LimitedSkolemisationApplication program = - new LimitedSkolemisationApplication(generalProgram, dProgram.getUpperBottomStrategy()); - Treatment treatment = new Pick4NegativeConceptNaive(this, program); - return materialise(program, treatment, gap); - } - public int materialise4SpecificQuery(Program generalProgram, QueryRecord record, BottomStrategy upperBottom) { if(isDisposed()) throw new DisposedException(); diff --git a/src/uk/ac/ox/cs/pagoda/multistage/StageQueryEngine.java b/src/uk/ac/ox/cs/pagoda/multistage/StageQueryEngine.java index ffca55a..65184ee 100644 --- a/src/uk/ac/ox/cs/pagoda/multistage/StageQueryEngine.java +++ b/src/uk/ac/ox/cs/pagoda/multistage/StageQueryEngine.java @@ -21,8 +21,6 @@ public abstract class StageQueryEngine extends BasicQueryEngine { public abstract int materialiseRestrictedly(DatalogProgram dProgram, GapByStore4ID gap); - public abstract int materialiseSkolemly(DatalogProgram dProgram, GapByStore4ID gap); - public boolean isValid() { if (!checkValidity) return true; if (validMaterialisation != null) return validMaterialisation; diff --git a/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java b/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java index 5878a57..291af27 100644 --- a/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java +++ b/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java @@ -188,6 +188,10 @@ public class QueryRecord extends Disposable { return new AnswerTuplesImp(answerVariables[0], gapAnswerTuples); } + public int getGapAnswersCount() { + return gapAnswerTuples.size(); + } + public String toString() { if(isDisposed()) throw new DisposedException(); diff --git a/src/uk/ac/ox/cs/pagoda/query/rollup/QueryGraph.java b/src/uk/ac/ox/cs/pagoda/query/rollup/QueryGraph.java index a567699..a09cf5b 100644 --- a/src/uk/ac/ox/cs/pagoda/query/rollup/QueryGraph.java +++ b/src/uk/ac/ox/cs/pagoda/query/rollup/QueryGraph.java @@ -81,6 +81,44 @@ public class QueryGraph { return axioms; } +// public Set getExistentialConditions(Map assignment) { +// if(!rollable_edges.isEmpty()) return null; +// +// OWLIndividual sub; +// Visitor visitor = new Visitor(factory, assignment); +// Set axioms = new HashSet<>(); +// for(Map.Entry> entry : concepts.map.entrySet()) { +// // TODO check correctness!!! +// if(existVars.contains(entry.getKey())) { +// OWLClassExpression conjunction = +// factory.getOWLObjectIntersectionOf(factory.getOWLThing()); +// for(OWLClassExpression owlClassExpression : entry.getValue()) { +// conjunction = factory.getOWLObjectIntersectionOf(conjunction, owlClassExpression.accept(visitor)); +// } +// axioms.add(conjunction); +//// continue; // previously the "then" contained only this +// } +// } +// return axioms; +// } + + public Set getExistentialAxioms() { + if(!rollable_edges.isEmpty()) return null; + + Set axioms = new HashSet<>(); + for(Map.Entry> entry : concepts.map.entrySet()) { + if(existVars.contains(entry.getKey())) { + OWLClassExpression conjunction = + factory.getOWLObjectIntersectionOf(factory.getOWLThing()); + for(OWLClassExpression owlClassExpression : entry.getValue()) { + conjunction = factory.getOWLObjectIntersectionOf(conjunction, owlClassExpression); + } + axioms.add(factory.getOWLSubClassOfAxiom(conjunction, factory.getOWLNothing())); + } + } + return axioms; + } + public Set getAssertions(Map assignment) { if(!rollable_edges.isEmpty()) return null; @@ -88,10 +126,21 @@ public class QueryGraph { Visitor visitor = new Visitor(factory, assignment); Set axioms = getPropertyAssertions(assignment); for(Map.Entry> entry : concepts.map.entrySet()) { - if(existVars.contains(entry.getKey())) continue; - sub = factory.getOWLNamedIndividual(IRI.create(getIndividual(entry.getKey(), assignment).getIRI())); - for(OWLClassExpression clsExp : entry.getValue()) { - axioms.add(factory.getOWLClassAssertionAxiom(clsExp.accept(visitor), sub)); + // TODO check correctness!!! + if(existVars.contains(entry.getKey())) { +// OWLClassExpression conjunction = +// factory.getOWLObjectIntersectionOf(factory.getOWLThing()); +// for(OWLClassExpression owlClassExpression : entry.getValue()) { +// conjunction = factory.getOWLObjectIntersectionOf(conjunction, owlClassExpression.accept(visitor)); +// } +// axioms.add(factory.getOWLSubClassOfAxiom(conjunction, factory.getOWLNothing())); + continue; // previously the "then" contained only this + } + else { + sub = factory.getOWLNamedIndividual(IRI.create(getIndividual(entry.getKey(), assignment).getIRI())); + for(OWLClassExpression clsExp : entry.getValue()) { + axioms.add(factory.getOWLClassAssertionAxiom(clsExp.accept(visitor), sub)); + } } } return axioms; diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java index 93fbc98..51cb44d 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java @@ -10,7 +10,6 @@ import uk.ac.ox.cs.pagoda.query.GapByStore4ID; import uk.ac.ox.cs.pagoda.query.GapByStore4ID2; import uk.ac.ox.cs.pagoda.query.QueryRecord; import uk.ac.ox.cs.pagoda.query.QueryRecord.Step; -import uk.ac.ox.cs.pagoda.reasoner.full.Checker; import uk.ac.ox.cs.pagoda.reasoner.light.BasicQueryEngine; import uk.ac.ox.cs.pagoda.reasoner.light.KarmaQueryEngine; import uk.ac.ox.cs.pagoda.rules.DatalogProgram; @@ -189,19 +188,21 @@ class MyQueryReasoner extends QueryReasoner { return; OWLOntology relevantOntologySubset = extractRelevantOntologySubset(queryRecord); -// queryRecord.saveRelevantOntology("./fragment_query" + queryRecord.getQueryID() + ".owl"); +// queryRecord.saveRelevantOntology("/home/alessandro/Desktop/test-relevant-ontology.owl"); if(properties.getUseSkolemUpperBound() && - querySkolemisedRelevantSubset(relevantOntologySubset, queryRecord)) + querySkolemisedRelevantSubset(relevantOntologySubset, queryRecord)) { return; + } Timer t = new Timer(); - Checker summarisedChecker = new HermitSummaryFilter(queryRecord, properties.getToCallHermiT()); + HermitSummaryFilter summarisedChecker = new HermitSummaryFilter(queryRecord, properties.getToCallHermiT()); summarisedChecker.check(queryRecord.getGapAnswers()); - summarisedChecker.dispose(); +// summarisedChecker.checkByFullReasoner(queryRecord.getGapAnswers()); Utility.logDebug("Total time for full reasoner: " + t.duration()); + queryRecord.markAsProcessed(); - Utility.logDebug("Difficulty of this query: " + queryRecord.getDifficulty()); + summarisedChecker.dispose(); } @Override diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java index 3a057ec..e8daa3b 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java @@ -206,7 +206,7 @@ public abstract class QueryReasoner extends Disposable { if you call twice, you will end up with a json file with multiple roots */ if(answerWriter != null) gson.toJson(queryRecords, answerWriter); // queryRecords.stream().forEach(record -> Utility.logDebug(gson.toJson(record))); - queryRecords.stream().forEach(record -> record.dispose()); + queryRecords.stream().forEach(QueryRecord::dispose); } @Override diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/full/Checker.java b/src/uk/ac/ox/cs/pagoda/reasoner/full/Checker.java index fd620a5..07adc6d 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/full/Checker.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/full/Checker.java @@ -12,4 +12,6 @@ public abstract class Checker extends Disposable { public abstract boolean isConsistent(); + public abstract int getNoOfCalls(); + } diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java b/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java index 35db0f2..cfae88b 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java @@ -24,228 +24,255 @@ import java.util.Map; import java.util.Set; public class HermitChecker extends Checker { - - protected OWLDataFactory factory; - protected String[][] answerVariable; - protected OWLOntology ontology; - protected QueryRecord record; - protected QueryGraph qGraph = null; - boolean toCheck = true; - AnswerTuple topAnswerTuple = null, botAnswerTuple = null; - private String queryText; - private DLClause queryClause; - private Reasoner hermit; - private int tag = 0; - private int counter = 0; - private DependencyGraph dGraph = null; - public HermitChecker(Checker checker) { - if (checker instanceof HermitChecker) { - HermitChecker other = (HermitChecker) checker; - factory = other.factory; - queryText = other.queryText; - queryClause = other.queryClause; - answerVariable = other.answerVariable; - ontology = other.ontology; + + protected OWLDataFactory factory; + protected String[][] answerVariable; + protected OWLOntology ontology; + protected QueryRecord record; + protected QueryGraph qGraph = null; + boolean toCheck = true; + AnswerTuple topAnswerTuple = null, botAnswerTuple = null; + private String queryText; + private DLClause queryClause; + private Reasoner hermit; + private int tag = 0; + + public int getNoOfCalls() { + if(isDisposed()) throw new DisposedException(); + return noOfCalls; + } + + private int noOfCalls = 0; + private DependencyGraph dGraph = null; + + public HermitChecker(Checker checker) { + if(checker instanceof HermitChecker) { + HermitChecker other = (HermitChecker) checker; + factory = other.factory; + queryText = other.queryText; + queryClause = other.queryClause; + answerVariable = other.answerVariable; + ontology = other.ontology; // record = other.record; - } + } - hermit = new Reasoner(ontology); - } + hermit = new Reasoner(ontology); + } - public HermitChecker(OWLOntology ontology, QueryRecord record, boolean toCheck) { - this.ontology = ontology; - queryText = record.getQueryText(); - answerVariable = record.getVariables(); - queryClause = record.getClause(); + public HermitChecker(OWLOntology ontology, QueryRecord record, boolean toCheck) { + this.ontology = ontology; + queryText = record.getQueryText(); + answerVariable = record.getVariables(); + queryClause = record.getClause(); // this.record = record; - this.toCheck = toCheck; - } - - public HermitChecker(OWLOntology ontology, String queryText) { - this.ontology = ontology; - this.queryText = queryText; - answerVariable = queryText == null ? null : ConjunctiveQueryHelper.getAnswerVariables(queryText); - queryClause = DLClauseHelper.getQuery(queryText, null); + this.toCheck = toCheck; + } + + public HermitChecker(OWLOntology ontology, String queryText) { + this.ontology = ontology; + this.queryText = queryText; + answerVariable = queryText == null ? null : ConjunctiveQueryHelper.getAnswerVariables(queryText); + queryClause = DLClauseHelper.getQuery(queryText, null); // this.record = null; - } - - @Override - public int check(AnswerTuples answers) { - if(isDisposed()) throw new DisposedException(); - - if(hermit == null) initialiseReasoner(); - int answerCounter = 0, counter = 0; - for(; answers.isValid(); answers.moveNext()) { - ++counter; - if(check(answers.getTuple())) ++answerCounter; - } - answers.dispose(); - - Utility.logDebug("The number of individuals to be checked by HermiT: " + counter, - "The number of correct answers: " + answerCounter); - return answerCounter; - } - - @Override - public boolean check(AnswerTuple answerTuple) { - if(isDisposed()) throw new DisposedException(); - - if(!toCheck) return false; - - if(hermit == null) initialiseReasoner(); - if(tag != 0) return tag == 1; - ++counter; - Timer t = new Timer(); - Map sub = answerTuple.getAssignment(answerVariable[1]); - Set toCheckAxioms = qGraph.getAssertions(sub); + } + + @Override + public int check(AnswerTuples answers) { + if(isDisposed()) throw new DisposedException(); + + if(hermit == null) initialiseReasoner(); + int answerCounter = 0, counter = 0; + for(; answers.isValid(); answers.moveNext()) { + ++counter; + if(check(answers.getTuple())) ++answerCounter; + } + answers.dispose(); + + Utility.logDebug("The number of individuals to be checked by HermiT: " + counter, + "The number of correct answers: " + answerCounter); + return answerCounter; + } + + @Override + public boolean check(AnswerTuple answerTuple) { + if(isDisposed()) throw new DisposedException(); + + if(!toCheck) return false; + ++noOfCalls; + + if(tag != 0) return tag == 1; + if(hermit == null) initialiseReasoner(); + + Timer t = new Timer(); + Map sub = answerTuple.getAssignment(answerVariable[1]); + Set toCheckAxioms = qGraph.getAssertions(sub); + + // TODO complete + Set toCheckExistentialAxioms = qGraph.getExistentialAxioms(); + + // TODO possibly inefficient + for(OWLAxiom subclassAxiom : toCheckExistentialAxioms) { + Utility.logDebug("Checking consistency of ontology union " + subclassAxiom); + ontology.getOWLOntologyManager().addAxiom(ontology, subclassAxiom); + if(hermit.isConsistent()) { + Utility.logDebug("@TIME to check one tuple: " + t.duration()); + return false; + } + ontology.getOWLOntologyManager().removeAxiom(ontology, subclassAxiom); + } + // for (OWLAxiom axiom: toCheckAxioms) System.out.println(axiom.toString()); - if(hermit.isEntailed(toCheckAxioms)) { - Utility.logDebug("@TIME to check one tuple: " + t.duration()); - return true; - } - Utility.logDebug("@TIME to check one tuple: " + t.duration()); - return false; - } - - @Override - public boolean isConsistent() { - if(isDisposed()) throw new DisposedException(); - - if(hermit == null) initialiseReasoner(); - return hermit.isConsistent(); - } - - public void dispose() { - super.dispose(); - - Utility.logInfo("Hermit was called " + counter + " times."); - if(hermit != null) hermit.dispose(); - hermit = null; - } - - public void setDependencyGraph(DependencyGraph dGraph) { - if(isDisposed()) throw new DisposedException(); - - this.dGraph = dGraph; - } - - private void initialiseReasoner() { - qGraph = new QueryGraph(queryClause.getBodyAtoms(), answerVariable[1], ontology); - OWLOntologyManager manager = ontology.getOWLOntologyManager(); - factory = manager.getOWLDataFactory(); - - if(hermit != null) hermit.dispose(); - - if(dGraph != null && answerVariable[1].length == 1 && (dGraph.getExits().size() > 1 || dGraph.getEntrances() - .size() > 1)) { - Set topAxioms = new HashSet(); - Set botAxioms = new HashSet(); - addTopAndBotTuple(topAxioms, botAxioms); - manager.addAxioms(ontology, topAxioms); - manager.addAxioms(ontology, botAxioms); - hermit = new Reasoner(ontology); - boolean topValid = true; - if(!hermit.isConsistent() || topAnswerTuple != null && (topValid = check(topAnswerTuple))) { - hermit.dispose(); - manager.removeAxioms(ontology, topAxioms); - hermit = new Reasoner(ontology); - } - else { - if(!topValid) tag = -1; - else if(botAnswerTuple != null && check(botAnswerTuple)) tag = 1; - } - } - else - hermit = new Reasoner(ontology); - } - - private void addTopAndBotTuple(Set topAxioms, Set botAxioms) { - String top_str = Namespace.PAGODA_ANONY + "top", bot_str = Namespace.PAGODA_ANONY + "bot"; - topAnswerTuple = - new AnswerTuple(new uk.ac.ox.cs.JRDFox.model.Individual[]{uk.ac.ox.cs.JRDFox.model.Individual.create(top_str)}); - botAnswerTuple = - new AnswerTuple(new uk.ac.ox.cs.JRDFox.model.Individual[]{uk.ac.ox.cs.JRDFox.model.Individual.create(bot_str)}); - OWLIndividual top_ind = factory.getOWLNamedIndividual(IRI.create(top_str)), bot_ind = - factory.getOWLNamedIndividual(IRI.create(bot_str)); - Map counter = new HashMap(); - - Set topAnswers = new HashSet(), botAnswers = new HashSet(); - OWLIndividual sub, obj; - if(dGraph.getExits().size() > 1) { - for(Clique answerClique : dGraph.getExits()) - topAnswers.add(((uk.ac.ox.cs.JRDFox.model.Individual) answerClique.getRepresentative() - .getAnswerTuple() - .getGroundTerm(0)).getIRI()); - } - else topAnswerTuple = null; - - if(dGraph.getEntrances().size() > 1) { - for(Clique answerClique : dGraph.getEntrances()) - botAnswers.add(((uk.ac.ox.cs.JRDFox.model.Individual) answerClique.getRepresentative() - .getAnswerTuple() - .getGroundTerm(0)).getIRI()); - } - else botAnswerTuple = null; - - for(OWLAxiom axiom : ontology.getABoxAxioms(true)) - if(axiom instanceof OWLClassAssertionAxiom) { - OWLClassAssertionAxiom ca = (OWLClassAssertionAxiom) axiom; - sub = ca.getIndividual(); - if(topAnswers.contains(sub.toStringID())) - topAxioms.add(factory.getOWLClassAssertionAxiom(ca.getClassExpression(), top_ind)); - if(botAnswers.contains(sub.toStringID())) - inc(counter, factory.getOWLClassAssertionAxiom(ca.getClassExpression(), bot_ind)); - } - else if(axiom instanceof OWLObjectPropertyAssertionAxiom) { - OWLObjectPropertyAssertionAxiom oa = (OWLObjectPropertyAssertionAxiom) axiom; - sub = oa.getSubject(); - obj = oa.getObject(); - if(topAnswers.contains(sub.toStringID())) - if(topAnswers.contains(obj.toStringID())) - topAxioms.add(factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), top_ind, top_ind)); - else - topAxioms.add(factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), top_ind, obj)); - else { - if(topAnswers.contains(obj.toStringID())) - topAxioms.add(factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), sub, top_ind)); - } - - if(botAnswers.contains(sub.toStringID())) - if(botAnswers.contains(obj.toStringID())) - inc(counter, factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), bot_ind, bot_ind)); - else - inc(counter, factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), bot_ind, obj)); - else { - if(botAnswers.contains(obj.toStringID())) - inc(counter, factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), sub, bot_ind)); - } - - } - else if(axiom instanceof OWLDataPropertyAssertionAxiom) { - OWLDataPropertyAssertionAxiom da = (OWLDataPropertyAssertionAxiom) axiom; - sub = da.getSubject(); - if(topAnswers.contains(sub.toStringID())) - topAxioms.add(factory.getOWLDataPropertyAssertionAxiom(da.getProperty(), top_ind, da.getObject())); - - if(botAnswers.contains(sub.toStringID())) - inc(counter, factory.getOWLDataPropertyAssertionAxiom(da.getProperty(), bot_ind, da.getObject())); - } - - int number = botAnswers.size(); - for(Map.Entry entry : counter.entrySet()) { - if(entry.getValue() == number) - botAxioms.add(entry.getKey()); - } - } - - private void inc(Map counter, OWLAxiom newAxiom) { - if(isDisposed()) throw new DisposedException(); - - Integer number = counter.get(newAxiom); - if(number == null) counter.put(newAxiom, 1); - else counter.put(newAxiom, number + 1); - } +// Utility.logInfo(toCheckAxioms); + + if(hermit.isEntailed(toCheckAxioms)) { + Utility.logDebug("@TIME to check one tuple: " + t.duration()); + return true; + } + Utility.logDebug("@TIME to check one tuple: " + t.duration()); + return false; + } + + @Override + public boolean isConsistent() { + if(isDisposed()) throw new DisposedException(); + + if(hermit == null) initialiseReasoner(); + return hermit.isConsistent(); + } + + public void dispose() { + super.dispose(); + + Utility.logDebug("Disposing of an instance of Hermit after " + noOfCalls + " calls"); + if(hermit != null) hermit.dispose(); + hermit = null; + } + + public void setDependencyGraph(DependencyGraph dGraph) { + if(isDisposed()) throw new DisposedException(); + + this.dGraph = dGraph; + } + + private void initialiseReasoner() { + qGraph = new QueryGraph(queryClause.getBodyAtoms(), answerVariable[1], ontology); + OWLOntologyManager manager = ontology.getOWLOntologyManager(); + factory = manager.getOWLDataFactory(); + + if(hermit != null) hermit.dispose(); + + if(dGraph != null && answerVariable[1].length == 1 && (dGraph.getExits().size() > 1 || dGraph.getEntrances() + .size() > 1)) { + Set topAxioms = new HashSet(); + Set botAxioms = new HashSet(); + addTopAndBotTuple(topAxioms, botAxioms); + manager.addAxioms(ontology, topAxioms); + manager.addAxioms(ontology, botAxioms); + hermit = new Reasoner(ontology); + boolean topValid = true; + if(!hermit.isConsistent() || topAnswerTuple != null && (topValid = check(topAnswerTuple))) { + hermit.dispose(); + manager.removeAxioms(ontology, topAxioms); + hermit = new Reasoner(ontology); + } + else { + if(!topValid) tag = -1; + else if(botAnswerTuple != null && check(botAnswerTuple)) tag = 1; + } + } + else + hermit = new Reasoner(ontology); + } + + private void addTopAndBotTuple(Set topAxioms, Set botAxioms) { + String top_str = Namespace.PAGODA_ANONY + "top", bot_str = Namespace.PAGODA_ANONY + "bot"; + topAnswerTuple = + new AnswerTuple( + new uk.ac.ox.cs.JRDFox.model.Individual[]{uk.ac.ox.cs.JRDFox.model.Individual.create(top_str)}); + botAnswerTuple = + new AnswerTuple( + new uk.ac.ox.cs.JRDFox.model.Individual[]{uk.ac.ox.cs.JRDFox.model.Individual.create(bot_str)}); + OWLIndividual top_ind = factory.getOWLNamedIndividual(IRI.create(top_str)), bot_ind = + factory.getOWLNamedIndividual(IRI.create(bot_str)); + Map counter = new HashMap(); + + Set topAnswers = new HashSet(), botAnswers = new HashSet(); + OWLIndividual sub, obj; + if(dGraph.getExits().size() > 1) { + for(Clique answerClique : dGraph.getExits()) + topAnswers.add(((uk.ac.ox.cs.JRDFox.model.Individual) answerClique.getRepresentative() + .getAnswerTuple() + .getGroundTerm(0)).getIRI()); + } + else topAnswerTuple = null; + + if(dGraph.getEntrances().size() > 1) { + for(Clique answerClique : dGraph.getEntrances()) + botAnswers.add(((uk.ac.ox.cs.JRDFox.model.Individual) answerClique.getRepresentative() + .getAnswerTuple() + .getGroundTerm(0)).getIRI()); + } + else botAnswerTuple = null; + + for(OWLAxiom axiom : ontology.getABoxAxioms(true)) + if(axiom instanceof OWLClassAssertionAxiom) { + OWLClassAssertionAxiom ca = (OWLClassAssertionAxiom) axiom; + sub = ca.getIndividual(); + if(topAnswers.contains(sub.toStringID())) + topAxioms.add(factory.getOWLClassAssertionAxiom(ca.getClassExpression(), top_ind)); + if(botAnswers.contains(sub.toStringID())) + inc(counter, factory.getOWLClassAssertionAxiom(ca.getClassExpression(), bot_ind)); + } + else if(axiom instanceof OWLObjectPropertyAssertionAxiom) { + OWLObjectPropertyAssertionAxiom oa = (OWLObjectPropertyAssertionAxiom) axiom; + sub = oa.getSubject(); + obj = oa.getObject(); + if(topAnswers.contains(sub.toStringID())) + if(topAnswers.contains(obj.toStringID())) + topAxioms.add(factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), top_ind, top_ind)); + else + topAxioms.add(factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), top_ind, obj)); + else { + if(topAnswers.contains(obj.toStringID())) + topAxioms.add(factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), sub, top_ind)); + } + + if(botAnswers.contains(sub.toStringID())) + if(botAnswers.contains(obj.toStringID())) + inc(counter, factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), bot_ind, bot_ind)); + else + inc(counter, factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), bot_ind, obj)); + else { + if(botAnswers.contains(obj.toStringID())) + inc(counter, factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), sub, bot_ind)); + } + + } + else if(axiom instanceof OWLDataPropertyAssertionAxiom) { + OWLDataPropertyAssertionAxiom da = (OWLDataPropertyAssertionAxiom) axiom; + sub = da.getSubject(); + if(topAnswers.contains(sub.toStringID())) + topAxioms.add(factory.getOWLDataPropertyAssertionAxiom(da.getProperty(), top_ind, da.getObject())); + + if(botAnswers.contains(sub.toStringID())) + inc(counter, factory.getOWLDataPropertyAssertionAxiom(da.getProperty(), bot_ind, da.getObject())); + } + + int number = botAnswers.size(); + for(Map.Entry entry : counter.entrySet()) { + if(entry.getValue() == number) + botAxioms.add(entry.getKey()); + } + } + + private void inc(Map counter, OWLAxiom newAxiom) { + if(isDisposed()) throw new DisposedException(); + + Integer number = counter.get(newAxiom); + if(number == null) counter.put(newAxiom, 1); + else counter.put(newAxiom, number + 1); + } } diff --git a/src/uk/ac/ox/cs/pagoda/rules/Program.java b/src/uk/ac/ox/cs/pagoda/rules/Program.java index afc32d4..85000e3 100644 --- a/src/uk/ac/ox/cs/pagoda/rules/Program.java +++ b/src/uk/ac/ox/cs/pagoda/rules/Program.java @@ -119,7 +119,7 @@ protected PredicateDependency dependencyGraph; } catch(IOException e) { e.printStackTrace(); } - Utility.logDebug("The rules are saved in " + getOutputPath() + "."); + Utility.logInfo("The rules are saved in " + getOutputPath() + "."); } @Override diff --git a/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java b/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java index f3f08e9..95f2cbb 100644 --- a/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java +++ b/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java @@ -110,6 +110,11 @@ public class HermitSummaryFilter extends Checker { return endomorphismChecker.isConsistent(); } + @Override + public int getNoOfCalls() { + return summarisedHermiT.getNoOfCalls() + endomorphismChecker.getNoOfCalls(); + } + @Override public int check(AnswerTuples answers) { if(isDisposed()) throw new DisposedException(); @@ -183,8 +188,14 @@ public class HermitSummaryFilter extends Checker { public void dispose() { super.dispose(); - if(summarisedHermiT != null) summarisedHermiT.dispose(); - endomorphismChecker.dispose(); + if(summarisedHermiT != null) { + Utility.logInfo("SummarisedHermit was called " + summarisedHermiT.getNoOfCalls() + " times"); + summarisedHermiT.dispose(); + } + if(endomorphismChecker != null) { + Utility.logInfo("Hermit was called " + endomorphismChecker.getNoOfCalls() + " times"); + endomorphismChecker.dispose(); + } } private void initialiseSummarisedReasoner() { diff --git a/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java b/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java index e501821..4991d0d 100644 --- a/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java +++ b/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java @@ -43,14 +43,14 @@ public class PagodaProperties { defaultUseAlwaysSimpleUpperBound = Boolean.parseBoolean(config.getProperty("useAlwaysSimpleUpperBound")); if(defaultUseAlwaysSimpleUpperBound) - logger.info("By default the simple upper bound is always used"); + logger.debug("By default the simple upper bound is always used"); } if(config.containsKey("useSkolemUpperBound")) { defaultUseSkolemUpperBound = Boolean.parseBoolean(config.getProperty("useSkolemUpperBound")); if(defaultUseSkolemUpperBound) - logger.info("By default the Skolem upper bound is enabled"); + logger.debug("By default the Skolem upper bound is enabled"); else - logger.info("By default the Skolem upper bound is disabled"); + logger.debug("By default the Skolem upper bound is disabled"); } } catch(IOException e) { diff --git a/test/resources/BugTests.xml b/test/resources/BugTests.xml new file mode 100644 index 0000000..5782bd4 --- /dev/null +++ b/test/resources/BugTests.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/resources/Correctness.xml b/test/resources/Correctness.xml new file mode 100644 index 0000000..3b00b7b --- /dev/null +++ b/test/resources/Correctness.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/resources/LightTests.xml b/test/resources/LightTests.xml index 2bc8dac..69cb572 100644 --- a/test/resources/LightTests.xml +++ b/test/resources/LightTests.xml @@ -5,8 +5,8 @@ - - + + diff --git a/test/resources/test.properties b/test/resources/test.properties index c4a25d0..08caeba 100644 --- a/test/resources/test.properties +++ b/test/resources/test.properties @@ -1 +1,2 @@ +#ontoDir=/home/alessandro/Desktop ontoDir=/home/alessandro/Big_files/Ontologies/ \ No newline at end of file diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/MinimumCardinalityTest.java b/test/uk/ac/ox/cs/pagoda/global_tests/MinimumCardinalityTest.java new file mode 100644 index 0000000..71c20c1 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/MinimumCardinalityTest.java @@ -0,0 +1,101 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.*; +import org.testng.Assert; +import org.testng.annotations.Test; +import uk.ac.ox.cs.pagoda.query.AnswerTuple; +import uk.ac.ox.cs.pagoda.query.AnswerTuples; +import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; + +public class MinimumCardinalityTest { + + public static final String NS = "http://example.org/test#%s"; + + private IRI getEntityIRI(String name) { + return IRI.create(String.format(NS, name)); + } + + @Test(groups = {"BugTesters"}) + public void test() throws OWLOntologyCreationException, IOException, OWLOntologyStorageException { + + /* + * Build test ontology + * */ + + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + OWLDataFactory factory = manager.getOWLDataFactory(); + OWLOntology ontology = manager.createOntology(); + + OWLClass student = factory.getOWLClass(getEntityIRI("Student")); + manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(student)); + OWLClass course = factory.getOWLClass(getEntityIRI("Course")); + manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(course)); + OWLClass hardWorkingStudent = factory.getOWLClass(getEntityIRI("HardWorkingStudent")); + manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(hardWorkingStudent)); + OWLNamedIndividual a = factory.getOWLNamedIndividual(getEntityIRI("a")); + OWLNamedIndividual b = factory.getOWLNamedIndividual(getEntityIRI("b")); + OWLNamedIndividual c1 = factory.getOWLNamedIndividual(getEntityIRI("c1")); + OWLNamedIndividual c2 = factory.getOWLNamedIndividual(getEntityIRI("c2")); + OWLNamedIndividual c3 = factory.getOWLNamedIndividual(getEntityIRI("c3")); + OWLNamedIndividual d1 = factory.getOWLNamedIndividual(getEntityIRI("d1")); + OWLNamedIndividual d2 = factory.getOWLNamedIndividual(getEntityIRI("d2")); + OWLNamedIndividual d3 = factory.getOWLNamedIndividual(getEntityIRI("d3")); + OWLObjectProperty takesCourse = factory.getOWLObjectProperty(IRI.create(String.format(NS, "takesCourse"))); + manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(takesCourse)); + + // Class assertions + manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(student, a)); // Student(a) + manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(student, b)); // Student(b) + manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(course, c1)); // Course(c1) + manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(course, c2)); // Course(c2) + manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(course, c3)); // Course(c3) + manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(course, d1)); // Course(d1) + manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(course, d2)); // Course(d2) + manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(course, d3)); // Course(d3) + + // Role assertions + manager.addAxiom(ontology, factory.getOWLObjectPropertyAssertionAxiom(takesCourse, a, c1)); // takesCourse(a,c1) + manager.addAxiom(ontology, factory.getOWLObjectPropertyAssertionAxiom(takesCourse, a, c2)); // takesCourse(a,c2) + manager.addAxiom(ontology, factory.getOWLObjectPropertyAssertionAxiom(takesCourse, a, c3)); // takesCourse(a,c3) + manager.addAxiom(ontology, factory.getOWLObjectPropertyAssertionAxiom(takesCourse, b, d1)); // takesCourse(b,d1) + manager.addAxiom(ontology, factory.getOWLObjectPropertyAssertionAxiom(takesCourse, b, d2)); // takesCourse(b,d2) + manager.addAxiom(ontology, factory.getOWLObjectPropertyAssertionAxiom(takesCourse, b, d3)); // takesCourse(b,d3) + + // Minimum cardinality axiom + manager.addAxiom(ontology, + factory.getOWLEquivalentClassesAxiom(hardWorkingStudent, + factory.getOWLObjectMinCardinality(3, + takesCourse))); + + manager.saveOntology(ontology, Files.newOutputStream(Paths.get("/home/alessandro/Desktop/test-ontology.owl"))); + + /* + * Test one query + * */ + + QueryReasoner pagoda = QueryReasoner.getInstance(ontology); + pagoda.loadOntology(ontology); + if (pagoda.preprocess()) { + String query = "select distinct ?x ?y " + + " where { " + + " ?x <" + takesCourse.toStringID() + "> _:z . " + + " ?y <" + takesCourse.toStringID() + "> _:z " + + " }"; + AnswerTuples answers = pagoda.evaluate(query); + int count = 0; + for (AnswerTuple ans; answers.isValid(); answers.moveNext()) { + ans = answers.getTuple(); + TestUtil.logInfo(ans); + count++; + } + Assert.assertEquals(count, 2); + } + pagoda.dispose(); + } +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java index a0ccb1a..caaad35 100644 --- a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java @@ -32,7 +32,7 @@ public class TestPagodaFLY { CheckAnswers.assertSameAnswers(answers, givenAnswers); } - @Test(groups = {"light"}) + @Test(groups = {"light", "correctness"}) public void answersCorrectness_rolledUp() throws IOException { String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); Path answers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath()); @@ -43,7 +43,7 @@ public class TestPagodaFLY { .ontology(Paths.get(ontoDir, "fly/fly_rolledUp.owl")) .query(Paths.get(ontoDir, "fly/queries/fly_rolledUp.sparql")) .answer(answers) - .answer(Paths.get("/home/alessandro/Desktop/answers.json")) +// .answer(Paths.get("/home/alessandro/Desktop/answers.json")) .classify(false) .hermit(true) .build(); @@ -68,7 +68,7 @@ public class TestPagodaFLY { .run(); } - @Test(groups = {"light", "comparison"}) + @Test(groups = {"comparison"}) public void compare_newQueries() throws IOException { String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaLUBM.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaLUBM.java index 089a7d2..fdbfc42 100644 --- a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaLUBM.java +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaLUBM.java @@ -31,7 +31,7 @@ public class TestPagodaLUBM { CheckAnswers.assertSameAnswers(answers, givenAnswers); } - @Test(groups = {"light"}) + @Test(groups = {"light", "correctness"}) public void answersCorrectness_1() throws IOException { answersCorrectness(1); } diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java index 1d9f1e6..d0f0b9a 100644 --- a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java @@ -24,12 +24,12 @@ public class TestPagodaUOBM { return integers; } - @Test(groups = {"light"}) + @Test(groups = {"light", "correctness"}) public void answersCorrectness_1() throws IOException { answersCorrectness(1); } - @Test(groups = {"heavy"}, dataProvider = "UOBMNumbers") + @Test(groups = {"heavy", "correctness"}, dataProvider = "UOBMNumbers") public void answersCorrectness(int number) throws IOException { String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); Path answers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath()); @@ -65,13 +65,11 @@ public class TestPagodaUOBM { .ontology(Paths.get(ontoDir, "uobm/univ-bench-dl.owl")) .data(Paths.get(ontoDir, "uobm/data/uobm" + number + ".ttl")) .query(Paths.get(ontoDir, "uobm/queries/uobm_sygenia.sparql")) -// .answer(answers) .classify(true) .hermit(true) .build(); pagoda.run(); -// CheckAnswers.assertSameAnswers(answers, givenAnswers); } @Test(groups = {"sygenia"}) @@ -82,21 +80,14 @@ public class TestPagodaUOBM { @Test(groups = {"heavy"}, dataProvider = "UOBMNumbers") public void answersCorrectness_sygenia_allBlanks(int number) throws IOException { String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); -// Path answers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath()); -// new File(answers.toString()).deleteOnExit(); -// Path givenAnswers = TestUtil.getAnswersFilePath("answers/pagoda-uobm" + number + ".json"); - Pagoda pagoda = Pagoda.builder() - .ontology(Paths.get(ontoDir, "uobm/univ-bench-dl.owl")) - .data(Paths.get(ontoDir, "uobm/data/uobm" + number + ".ttl")) - .query(Paths.get(ontoDir, "uobm/queries/uobm_sygenia_all-blanks.sparql")) -// .answer(answers) - .classify(true) - .hermit(true) - .build(); - - pagoda.run(); -// CheckAnswers.assertSameAnswers(answers, givenAnswers); + Pagoda.builder() + .ontology(Paths.get(ontoDir, "uobm/univ-bench-dl.owl")) + .data(Paths.get(ontoDir, "uobm/data/uobm" + number + ".ttl")) + .query(Paths.get(ontoDir, "uobm/queries/uobm_sygenia_all-blanks.sparql")) + .classify(true) + .hermit(true) + .build().run(); } @Test(groups = {"justExecute"}) @@ -104,14 +95,12 @@ public class TestPagodaUOBM { String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); Pagoda.builder() - .ontology(Paths.get(ontoDir, "uobm/univ-bench-dl.owl")) + .ontology(Paths.get(ontoDir, "uobm/univ-bench-dl-modified.owl")) .data(Paths.get(ontoDir, "uobm/data/uobm1.ttl")) - .query(Paths.get(ontoDir, "uobm/queries/existential_queries.sparql")) -// .answer(answers) - .classify(true) - .hermit(true) - .skolem(false) - .build() - .run(); + .query(Paths.get(ontoDir, "uobm/queries/existential_queries.sparql")) + .classify(true) + .hermit(true) + .build() + .run(); } } -- cgit v1.2.3