From 17bd9beaf7f358a44e5bf36a5855fe6727d506dc Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Tue, 10 May 2022 18:17:06 +0100 Subject: [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. --- .../semanticweb/simpleETL/RDFHandlerWriter.java | 45 ------------- src/org/semanticweb/simpleETL/SimpleETL.java | 76 ---------------------- 2 files changed, 121 deletions(-) delete mode 100644 src/org/semanticweb/simpleETL/RDFHandlerWriter.java delete mode 100644 src/org/semanticweb/simpleETL/SimpleETL.java (limited to 'src/org/semanticweb/simpleETL') 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 @@ -package org.semanticweb.simpleETL; -import org.openrdf.model.Statement; -import org.openrdf.rio.RDFHandler; -import org.openrdf.rio.RDFHandlerException; -import org.openrdf.rio.RDFWriter; - - -public class RDFHandlerWriter implements RDFHandler { - protected RDFWriter m_writer; - protected boolean m_started; - - public RDFHandlerWriter(RDFWriter writer){ - m_writer = writer; - m_started = false; - } - - @Override - public void endRDF() throws RDFHandlerException { - // Do not end - } - - @Override - public void handleComment(String arg0) throws RDFHandlerException { - m_writer.handleComment(arg0); - - } - - @Override - public void handleNamespace(String arg0, String arg1) throws RDFHandlerException { - m_writer.handleNamespace(arg0, arg1); - } - - @Override - public void handleStatement(Statement arg0) throws RDFHandlerException { - m_writer.handleStatement(arg0); - } - - @Override - public void startRDF() throws RDFHandlerException { - if(!m_started) { - m_started = true; - m_writer.startRDF(); - } - } -} 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 @@ -package org.semanticweb.simpleETL; - -import org.openrdf.rio.RDFParser; -import org.openrdf.rio.RDFWriter; -import org.openrdf.rio.rdfxml.RDFXMLParser; -import org.openrdf.rio.turtle.TurtleWriter; -import uk.ac.ox.cs.pagoda.util.Utility; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.util.regex.Pattern; - -public class SimpleETL { - - protected final static String m_prefix_LUBM = "http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#"; - protected final static String m_prefix_UOBM = "http://semantics.crl.ibm.com/univ-bench-dl.owl#"; - protected final static String m_prefix_FLY= "http://www.virtualflybrain.org/ontologies/individual_neurons/FC_neuron_GF_an.owl#"; - - String m_prefix; - String m_fileToImport; - String m_fileToExport; - - public SimpleETL(String prefix, String fileToImport) { - m_prefix = prefix; - m_fileToImport = fileToImport; - m_fileToExport = m_fileToImport.replace(".owl", ".ttl"); - } - - public SimpleETL(String prefix, String fileToImport, String outPath) { - m_prefix = prefix; - m_fileToImport = fileToImport; - File file = new File(outPath); - if (file.exists() && file.isDirectory()) - m_fileToExport = outPath + Utility.FILE_SEPARATOR + "data.ttl"; - else - m_fileToExport = outPath; -// + Utility.FILE_SEPARATOR + m_fileToImport.substring(m_fileToImport.lastIndexOf(Utility.FILE_SEPARATOR), m_fileToImport.lastIndexOf(".")) + ".ttl"; - } - - public void rewrite() throws Exception { -// RDFParser parser = new TurtleParser(); - RDFParser parser = new RDFXMLParser(); - - FileOutputStream fos = new FileOutputStream(m_fileToExport); - try { - RDFWriter writer = new TurtleWriter(fos); - -// String m_fileToExport = m_fileToImport.replace(".owl", ".ntriple"); -// RDFWriter writer = new NTriplesWriter(new FileOutputStream(m_fileToExport)); - - RDFHandlerWriter multiHandler = new RDFHandlerWriter(writer); - parser.setRDFHandler(multiHandler); - File fileToImport = new File(m_fileToImport); - if(fileToImport.isDirectory()) { - for(File file : fileToImport.listFiles()) { - if(file.isFile() && (Pattern.matches(".*.owl", file.getName()) || Pattern.matches(".*.rdf", file.getName()))) { - Utility.logDebug("Parsing " + file.getName()); - parser.parse(new FileInputStream(file), m_prefix); - } - } - } - else - parser.parse(new FileInputStream(fileToImport), m_prefix); - writer.endRDF(); - } - finally { - fos.close(); - } - Utility.logDebug("SimpleETL rewriting DONE: additional ontology data is saved in " + m_fileToExport + "."); - } - - public String getExportedFile() { - return m_fileToExport; - } -} -- cgit v1.2.3