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 /src/uk/ac/ox/cs | |
| parent | b8212705e65db860bbb899b16fa0e7bc9e8536cf (diff) | |
| download | ACQuA-6a559a415b3bdb3048021839e5bcf5bbf5aa4bbd.tar.gz ACQuA-6a559a415b3bdb3048021839e5bcf5bbf5aa4bbd.zip | |
Anonymous ontology id.
Diffstat (limited to 'src/uk/ac/ox/cs')
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java | 12 |
1 files changed, 8 insertions, 4 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 | ||
