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. --- .../ox/cs/pagoda/util/ConjunctiveQueryHelper.java | 70 ---------------------- 1 file changed, 70 deletions(-) delete mode 100644 src/uk/ac/ox/cs/pagoda/util/ConjunctiveQueryHelper.java (limited to 'src/uk/ac/ox/cs/pagoda/util/ConjunctiveQueryHelper.java') diff --git a/src/uk/ac/ox/cs/pagoda/util/ConjunctiveQueryHelper.java b/src/uk/ac/ox/cs/pagoda/util/ConjunctiveQueryHelper.java deleted file mode 100644 index 937c2c4..0000000 --- a/src/uk/ac/ox/cs/pagoda/util/ConjunctiveQueryHelper.java +++ /dev/null @@ -1,70 +0,0 @@ -package uk.ac.ox.cs.pagoda.util; - -import java.util.Collection; -import java.util.HashSet; -import java.util.LinkedList; - -public class ConjunctiveQueryHelper { - - public static String[][] getAnswerVariables(String queryText) { - Collection disVars = new LinkedList(), undisVars = new LinkedList(); - for (String var: getAllVariables(queryText)) - if (var.startsWith("?")) disVars.add(var.substring(1)); - else undisVars.add(var.substring(2)); - - String[] distinguishedVariables = disVars.toArray(new String[0]); - String[] undistinguishedVariables = undisVars.toArray(new String[0]); - String[] answerVariables = null; - - String uppercase = queryText.toUpperCase(); - int selectIndex = uppercase.indexOf("SELECT"); - int whereIndex = uppercase.indexOf("WHERE"); - String selectClause = queryText.substring(selectIndex + 6, whereIndex); - if (selectClause.contains("*")) answerVariables = distinguishedVariables; - else { - String[] terms = selectClause.split(" "); - int num = 0; - for (int i = 0; i < terms.length; ++i) - if (terms[i].startsWith("?")) ++num; - answerVariables = new String[num]; - for (int i = 0, j = 0; i < terms.length; ++i) - if (terms[i].startsWith("?")) - answerVariables[j++] = terms[i].substring(1); - } - - if (answerVariables != distinguishedVariables) { - int index = 0; - for (; index < answerVariables.length; ++index) { - distinguishedVariables[index] = answerVariables[index]; - disVars.remove(answerVariables[index]); - } - for (String var: disVars) - distinguishedVariables[index++] = var; - } - - return new String[][] { answerVariables, distinguishedVariables, undistinguishedVariables }; - } - - private static Collection getAllVariables(String queryText) { - Collection vars = new HashSet(); - int start, end = 0; - char ch; - while ((start = queryText.indexOf("?", end)) != -1) { - end = start + 1; - while (end + 1 < queryText.length() && (ch = queryText.charAt(end + 1)) != '\n' && ch != ' ') - ++end; - vars.add(queryText.substring(start, end + 1)); - } - - end = 0; - while ((start = queryText.indexOf("_:", end)) != -1) { - end = start + 1; - while (end + 1 < queryText.length() && (ch = queryText.charAt(end + 1)) != '\n' && ch != ' ') - ++end; - vars.add(queryText.substring(start, end + 1)); - } - - return vars; - } - -} -- cgit v1.2.3