diff options
| author | yzhou <yujiao.zhou@gmail.com> | 2015-04-21 10:34:27 +0100 |
|---|---|---|
| committer | yzhou <yujiao.zhou@gmail.com> | 2015-04-21 10:34:27 +0100 |
| commit | 9ce65c5a963b03ee97fe9cb6c5aa65a3c04a80a8 (patch) | |
| tree | 47511c0fb89dccff0db4b5990522e04f294d795b /test/uk/ac/ox/cs/data/RemoveDataPropertyRange.java | |
| parent | b1ac207612ee8b045244253fb94b866104bc34f2 (diff) | |
| download | ACQuA-9ce65c5a963b03ee97fe9cb6c5aa65a3c04a80a8.tar.gz ACQuA-9ce65c5a963b03ee97fe9cb6c5aa65a3c04a80a8.zip | |
initial version
Diffstat (limited to 'test/uk/ac/ox/cs/data/RemoveDataPropertyRange.java')
| -rw-r--r-- | test/uk/ac/ox/cs/data/RemoveDataPropertyRange.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/uk/ac/ox/cs/data/RemoveDataPropertyRange.java b/test/uk/ac/ox/cs/data/RemoveDataPropertyRange.java new file mode 100644 index 0000000..acaa91b --- /dev/null +++ b/test/uk/ac/ox/cs/data/RemoveDataPropertyRange.java | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | package uk.ac.ox.cs.data; | ||
| 2 | |||
| 3 | import java.io.File; | ||
| 4 | import java.io.FileOutputStream; | ||
| 5 | import java.io.IOException; | ||
| 6 | |||
| 7 | import org.semanticweb.owlapi.apibinding.OWLManager; | ||
| 8 | import org.semanticweb.owlapi.model.OWLAxiom; | ||
| 9 | import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; | ||
| 10 | import org.semanticweb.owlapi.model.OWLException; | ||
| 11 | import org.semanticweb.owlapi.model.OWLOntology; | ||
| 12 | import org.semanticweb.owlapi.model.OWLOntologyManager; | ||
| 13 | |||
| 14 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; | ||
| 15 | import uk.ac.ox.cs.pagoda.util.Utility; | ||
| 16 | |||
| 17 | public class RemoveDataPropertyRange { | ||
| 18 | |||
| 19 | public static void process(String file) throws OWLException, IOException { | ||
| 20 | OWLOntologyManager originalManager = OWLManager.createOWLOntologyManager(); | ||
| 21 | OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); | ||
| 22 | |||
| 23 | OWLOntology originalOntology = originalManager.loadOntologyFromOntologyDocument(new File(file)); | ||
| 24 | OWLOntology ontology = manager.createOntology(originalOntology.getOntologyID().getOntologyIRI()); | ||
| 25 | |||
| 26 | for (OWLOntology onto: originalOntology.getImportsClosure()) | ||
| 27 | for (OWLAxiom axiom: onto.getAxioms()) { | ||
| 28 | if (!(axiom instanceof OWLDataPropertyRangeAxiom)) | ||
| 29 | manager.addAxiom(ontology, axiom); | ||
| 30 | } | ||
| 31 | originalManager.removeOntology(originalOntology); | ||
| 32 | |||
| 33 | String extension = file.substring(file.lastIndexOf(".")); | ||
| 34 | String fileName = file.substring(file.lastIndexOf(Utility.FILE_SEPARATOR) + 1); | ||
| 35 | String dest = fileName.replace(extension, "-noDPR.owl"); | ||
| 36 | manager.saveOntology(ontology, new FileOutputStream(dest)); | ||
| 37 | System.out.println("The processed ontology is saved in " + dest + " successfully."); | ||
| 38 | manager.removeOntology(ontology); | ||
| 39 | } | ||
| 40 | |||
| 41 | public static void main(String[] args) { | ||
| 42 | try { | ||
| 43 | process(PagodaTester.chembl_tbox); | ||
| 44 | } catch (OWLException e) { | ||
| 45 | e.printStackTrace(); | ||
| 46 | } catch (IOException e) { | ||
| 47 | e.printStackTrace(); | ||
| 48 | } | ||
| 49 | |||
| 50 | } | ||
| 51 | |||
| 52 | } | ||
