diff options
| author | RncLsn <rnc.lsn@gmail.com> | 2015-05-29 11:37:19 +0100 |
|---|---|---|
| committer | RncLsn <rnc.lsn@gmail.com> | 2015-05-29 11:37:19 +0100 |
| commit | 6a559a415b3bdb3048021839e5bcf5bbf5aa4bbd (patch) | |
| tree | 4aa9a4a21e01236e3b4fa27f69a7bd831b7fd8ca | |
| parent | b8212705e65db860bbb899b16fa0e7bc9e8536cf (diff) | |
| download | ACQuA-6a559a415b3bdb3048021839e5bcf5bbf5aa4bbd.tar.gz ACQuA-6a559a415b3bdb3048021839e5bcf5bbf5aa4bbd.zip | |
Anonymous ontology id.
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java | 12 | ||||
| -rw-r--r-- | test/resources/LightTests.xml | 4 | ||||
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/query/CheckAnswers.java | 3 |
3 files changed, 11 insertions, 8 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java b/src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java index d961223..b92bceb 100644 --- a/src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java +++ b/src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java | |||
| @@ -18,10 +18,13 @@ import uk.ac.ox.cs.pagoda.util.Utility; | |||
| 18 | import java.io.*; | 18 | import java.io.*; |
| 19 | import java.nio.file.Paths; | 19 | import java.nio.file.Paths; |
| 20 | import java.util.*; | 20 | import java.util.*; |
| 21 | import java.util.regex.Matcher; | ||
| 22 | import java.util.regex.Pattern; | ||
| 21 | 23 | ||
| 22 | public class RLPlusOntology implements KnowledgeBase { | 24 | public class RLPlusOntology implements KnowledgeBase { |
| 23 | 25 | ||
| 24 | private static final String DEFAULT_ONTOLOGY_FILE_EXTENSION = "owl"; | 26 | private static final String DEFAULT_ONTOLOGY_FILE_EXTENSION = "owl"; |
| 27 | private static final Pattern ONTOLOGY_ID_REGEX = Pattern.compile("ontologyid\\((?<id>[a-z0-9\\-]+)\\)"); | ||
| 25 | OWLOntologyManager manager; | 28 | OWLOntologyManager manager; |
| 26 | OWLDataFactory factory; | 29 | OWLDataFactory factory; |
| 27 | String ontologyIRI; | 30 | String ontologyIRI; |
| @@ -61,9 +64,10 @@ public class RLPlusOntology implements KnowledgeBase { | |||
| 61 | try { | 64 | try { |
| 62 | IRI ontologyIri; | 65 | IRI ontologyIri; |
| 63 | if(ontology.isAnonymous()) { | 66 | if(ontology.isAnonymous()) { |
| 64 | String anonymousOntologySuffix = Long.toString(System.currentTimeMillis()); | 67 | Matcher matcher = ONTOLOGY_ID_REGEX.matcher(ontology.getOntologyID().toString().toLowerCase()); |
| 65 | ontologyIri = IRI.create("http://www.example.org/", "anonymous-ontology-" | 68 | if(!matcher.matches()) throw new Error("Anonymous ontology without internal id"); |
| 66 | + anonymousOntologySuffix + "." + DEFAULT_ONTOLOGY_FILE_EXTENSION); | 69 | ontologyIri = |
| 70 | IRI.create("http://www.example.org/", matcher.group("id") + "." + DEFAULT_ONTOLOGY_FILE_EXTENSION); | ||
| 67 | } | 71 | } |
| 68 | else | 72 | else |
| 69 | ontologyIri = inputOntology.getOntologyID().getOntologyIRI(); | 73 | ontologyIri = inputOntology.getOntologyID().getOntologyIRI(); |
| @@ -79,7 +83,7 @@ public class RLPlusOntology implements KnowledgeBase { | |||
| 79 | IRI rlOntologyIRI = IRI.create(ontologyIriPrefix, originalFileName + "-RL." + originalExtension); | 83 | IRI rlOntologyIRI = IRI.create(ontologyIriPrefix, originalFileName + "-RL." + originalExtension); |
| 80 | outputPath = Paths.get(Utility.getGlobalTempDirAbsolutePath(), | 84 | outputPath = Paths.get(Utility.getGlobalTempDirAbsolutePath(), |
| 81 | originalFileName + "-RL." + originalExtension).toString(); | 85 | originalFileName + "-RL." + originalExtension).toString(); |
| 82 | IRI rlDocumentIRI = IRI.create(outputPath); | 86 | IRI rlDocumentIRI = IRI.create("file://" + outputPath); |
| 83 | outputOntology = manager.createOntology(rlOntologyIRI); | 87 | outputOntology = manager.createOntology(rlOntologyIRI); |
| 84 | manager.setOntologyDocumentIRI(outputOntology, rlDocumentIRI); | 88 | manager.setOntologyDocumentIRI(outputOntology, rlDocumentIRI); |
| 85 | 89 | ||
diff --git a/test/resources/LightTests.xml b/test/resources/LightTests.xml index bd0ea93..a30c436 100644 --- a/test/resources/LightTests.xml +++ b/test/resources/LightTests.xml | |||
| @@ -11,8 +11,8 @@ | |||
| 11 | 11 | ||
| 12 | <classes> | 12 | <classes> |
| 13 | <class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaUOBM"/> | 13 | <class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaUOBM"/> |
| 14 | <class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaLUBM"/> | 14 | <!--<class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaLUBM"/>--> |
| 15 | <class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaFLY"/> | 15 | <!--<class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaFLY"/>--> |
| 16 | </classes> | 16 | </classes> |
| 17 | </test> | 17 | </test> |
| 18 | </suite> \ No newline at end of file | 18 | </suite> \ No newline at end of file |
diff --git a/test/uk/ac/ox/cs/pagoda/query/CheckAnswers.java b/test/uk/ac/ox/cs/pagoda/query/CheckAnswers.java index f16d657..97e3a57 100644 --- a/test/uk/ac/ox/cs/pagoda/query/CheckAnswers.java +++ b/test/uk/ac/ox/cs/pagoda/query/CheckAnswers.java | |||
| @@ -31,7 +31,6 @@ public class CheckAnswers { | |||
| 31 | Set<QueryRecord> givenAnswersRecords = gson.fromJson(givenReader, cqType); | 31 | Set<QueryRecord> givenAnswersRecords = gson.fromJson(givenReader, cqType); |
| 32 | 32 | ||
| 33 | for(QueryRecord computedAnswersRecord : computedAnswersRecords) { | 33 | for(QueryRecord computedAnswersRecord : computedAnswersRecords) { |
| 34 | if(computedAnswersRecord.queryID == 8) continue; // DEBUG | ||
| 35 | Set<AnswerTuple> givenAnswers = null; | 34 | Set<AnswerTuple> givenAnswers = null; |
| 36 | for(QueryRecord givenAnswersRecord : givenAnswersRecords) { | 35 | for(QueryRecord givenAnswersRecord : givenAnswersRecords) { |
| 37 | if(givenAnswersRecord.queryID == computedAnswersRecord.queryID) { | 36 | if(givenAnswersRecord.queryID == computedAnswersRecord.queryID) { |
| @@ -44,7 +43,7 @@ public class CheckAnswers { | |||
| 44 | 43 | ||
| 45 | Set<AnswerTuple> computedAnswers = computedAnswersRecord.soundAnswerTuples; | 44 | Set<AnswerTuple> computedAnswers = computedAnswersRecord.soundAnswerTuples; |
| 46 | Assert.assertEquals(computedAnswers.size(), givenAnswers.size(), | 45 | Assert.assertEquals(computedAnswers.size(), givenAnswers.size(), |
| 47 | "Different number sound answers for query " + computedAnswersRecord.queryID + "!" | 46 | "Different number of sound answers for query " + computedAnswersRecord.queryID + "!" |
| 48 | + "Expected " + givenAnswers.size() + ", got " + computedAnswers.size()); | 47 | + "Expected " + givenAnswers.size() + ", got " + computedAnswers.size()); |
| 49 | Assert.assertEquals(computedAnswers, givenAnswers, | 48 | Assert.assertEquals(computedAnswers, givenAnswers, |
| 50 | "Different sound answers for query " + computedAnswersRecord.queryID + "!"); | 49 | "Different sound answers for query " + computedAnswersRecord.queryID + "!"); |
