aboutsummaryrefslogtreecommitdiff
path: root/src/org/semanticweb/simpleETL
diff options
context:
space:
mode:
authorFederico Igne <federico.igne@cs.ox.ac.uk>2022-05-10 18:17:06 +0100
committerFederico Igne <federico.igne@cs.ox.ac.uk>2022-05-11 12:34:47 +0100
commit17bd9beaf7f358a44e5bf36a5855fe6727d506dc (patch)
tree47e9310a0cff869d9ec017dcb2c81876407782c8 /src/org/semanticweb/simpleETL
parent8651164cd632a5db310b457ce32d4fbc97bdc41c (diff)
downloadACQuA-17bd9beaf7f358a44e5bf36a5855fe6727d506dc.tar.gz
ACQuA-17bd9beaf7f358a44e5bf36a5855fe6727d506dc.zip
[pagoda] Move project to Scala
This commit includes a few changes: - The repository still uses Maven to manage dependency but it is now a Scala project. - The code has been ported from OWLAPI 3.4.10 to 5.1.20 - A proof of concept program using both RSAComb and PAGOdA has been added.
Diffstat (limited to 'src/org/semanticweb/simpleETL')
-rw-r--r--src/org/semanticweb/simpleETL/RDFHandlerWriter.java45
-rw-r--r--src/org/semanticweb/simpleETL/SimpleETL.java76
2 files changed, 0 insertions, 121 deletions
diff --git a/src/org/semanticweb/simpleETL/RDFHandlerWriter.java b/src/org/semanticweb/simpleETL/RDFHandlerWriter.java
deleted file mode 100644
index e5e2e2a..0000000
--- a/src/org/semanticweb/simpleETL/RDFHandlerWriter.java
+++ /dev/null
@@ -1,45 +0,0 @@
1package org.semanticweb.simpleETL;
2import org.openrdf.model.Statement;
3import org.openrdf.rio.RDFHandler;
4import org.openrdf.rio.RDFHandlerException;
5import org.openrdf.rio.RDFWriter;
6
7
8public class RDFHandlerWriter implements RDFHandler {
9 protected RDFWriter m_writer;
10 protected boolean m_started;
11
12 public RDFHandlerWriter(RDFWriter writer){
13 m_writer = writer;
14 m_started = false;
15 }
16
17 @Override
18 public void endRDF() throws RDFHandlerException {
19 // Do not end
20 }
21
22 @Override
23 public void handleComment(String arg0) throws RDFHandlerException {
24 m_writer.handleComment(arg0);
25
26 }
27
28 @Override
29 public void handleNamespace(String arg0, String arg1) throws RDFHandlerException {
30 m_writer.handleNamespace(arg0, arg1);
31 }
32
33 @Override
34 public void handleStatement(Statement arg0) throws RDFHandlerException {
35 m_writer.handleStatement(arg0);
36 }
37
38 @Override
39 public void startRDF() throws RDFHandlerException {
40 if(!m_started) {
41 m_started = true;
42 m_writer.startRDF();
43 }
44 }
45}
diff --git a/src/org/semanticweb/simpleETL/SimpleETL.java b/src/org/semanticweb/simpleETL/SimpleETL.java
deleted file mode 100644
index cc91e1f..0000000
--- a/src/org/semanticweb/simpleETL/SimpleETL.java
+++ /dev/null
@@ -1,76 +0,0 @@
1package org.semanticweb.simpleETL;
2
3import org.openrdf.rio.RDFParser;
4import org.openrdf.rio.RDFWriter;
5import org.openrdf.rio.rdfxml.RDFXMLParser;
6import org.openrdf.rio.turtle.TurtleWriter;
7import uk.ac.ox.cs.pagoda.util.Utility;
8
9import java.io.File;
10import java.io.FileInputStream;
11import java.io.FileOutputStream;
12import java.util.regex.Pattern;
13
14public class SimpleETL {
15
16 protected final static String m_prefix_LUBM = "http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#";
17 protected final static String m_prefix_UOBM = "http://semantics.crl.ibm.com/univ-bench-dl.owl#";
18 protected final static String m_prefix_FLY= "http://www.virtualflybrain.org/ontologies/individual_neurons/FC_neuron_GF_an.owl#";
19
20 String m_prefix;
21 String m_fileToImport;
22 String m_fileToExport;
23
24 public SimpleETL(String prefix, String fileToImport) {
25 m_prefix = prefix;
26 m_fileToImport = fileToImport;
27 m_fileToExport = m_fileToImport.replace(".owl", ".ttl");
28 }
29
30 public SimpleETL(String prefix, String fileToImport, String outPath) {
31 m_prefix = prefix;
32 m_fileToImport = fileToImport;
33 File file = new File(outPath);
34 if (file.exists() && file.isDirectory())
35 m_fileToExport = outPath + Utility.FILE_SEPARATOR + "data.ttl";
36 else
37 m_fileToExport = outPath;
38// + Utility.FILE_SEPARATOR + m_fileToImport.substring(m_fileToImport.lastIndexOf(Utility.FILE_SEPARATOR), m_fileToImport.lastIndexOf(".")) + ".ttl";
39 }
40
41 public void rewrite() throws Exception {
42// RDFParser parser = new TurtleParser();
43 RDFParser parser = new RDFXMLParser();
44
45 FileOutputStream fos = new FileOutputStream(m_fileToExport);
46 try {
47 RDFWriter writer = new TurtleWriter(fos);
48
49// String m_fileToExport = m_fileToImport.replace(".owl", ".ntriple");
50// RDFWriter writer = new NTriplesWriter(new FileOutputStream(m_fileToExport));
51
52 RDFHandlerWriter multiHandler = new RDFHandlerWriter(writer);
53 parser.setRDFHandler(multiHandler);
54 File fileToImport = new File(m_fileToImport);
55 if(fileToImport.isDirectory()) {
56 for(File file : fileToImport.listFiles()) {
57 if(file.isFile() && (Pattern.matches(".*.owl", file.getName()) || Pattern.matches(".*.rdf", file.getName()))) {
58 Utility.logDebug("Parsing " + file.getName());
59 parser.parse(new FileInputStream(file), m_prefix);
60 }
61 }
62 }
63 else
64 parser.parse(new FileInputStream(fileToImport), m_prefix);
65 writer.endRDF();
66 }
67 finally {
68 fos.close();
69 }
70 Utility.logDebug("SimpleETL rewriting DONE: additional ontology data is saved in " + m_fileToExport + ".");
71 }
72
73 public String getExportedFile() {
74 return m_fileToExport;
75 }
76}