aboutsummaryrefslogtreecommitdiff
path: root/src/uk/ac/ox/cs
diff options
context:
space:
mode:
authorRncLsn <rnc.lsn@gmail.com>2015-05-29 11:37:19 +0100
committerRncLsn <rnc.lsn@gmail.com>2015-05-29 11:37:19 +0100
commit6a559a415b3bdb3048021839e5bcf5bbf5aa4bbd (patch)
tree4aa9a4a21e01236e3b4fa27f69a7bd831b7fd8ca /src/uk/ac/ox/cs
parentb8212705e65db860bbb899b16fa0e7bc9e8536cf (diff)
downloadACQuA-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.java12
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;
18import java.io.*; 18import java.io.*;
19import java.nio.file.Paths; 19import java.nio.file.Paths;
20import java.util.*; 20import java.util.*;
21import java.util.regex.Matcher;
22import java.util.regex.Pattern;
21 23
22public class RLPlusOntology implements KnowledgeBase { 24public 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