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. --- src/uk/ac/ox/cs/pagoda/query/QueryManager.java | 123 ------------------------- 1 file changed, 123 deletions(-) delete mode 100644 src/uk/ac/ox/cs/pagoda/query/QueryManager.java (limited to 'src/uk/ac/ox/cs/pagoda/query/QueryManager.java') diff --git a/src/uk/ac/ox/cs/pagoda/query/QueryManager.java b/src/uk/ac/ox/cs/pagoda/query/QueryManager.java deleted file mode 100644 index 419cb97..0000000 --- a/src/uk/ac/ox/cs/pagoda/query/QueryManager.java +++ /dev/null @@ -1,123 +0,0 @@ -package uk.ac.ox.cs.pagoda.query; - -import java.io.File; -import java.io.FileNotFoundException; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.Scanner; - -import uk.ac.ox.cs.pagoda.util.Utility; - -public class QueryManager { - - public Collection collectQueryRecords(String queryfile) { - Collection ret = new LinkedList(); - for (String queryText: collectQueryTexts(queryfile)) - ret.add(create(queryText)); - return ret; - } - - public static Collection collectQueryTexts(String queryfile) { - Scanner scanner = null; - try { - scanner = new Scanner(new File(queryfile)); - } catch (FileNotFoundException e) { - e.printStackTrace(); - return null; - } - Collection ret = new LinkedList(); - - StringBuilder sb = new StringBuilder(); - int leftToMatch; - String text; - while (scanner.hasNextLine()) { - leftToMatch = -1; - for (String line; scanner.hasNextLine(); ) { - line = scanner.nextLine(); - if (line.length() > 6 && line.substring(0, 6).equalsIgnoreCase("SELECT")) { - String next = line.split(" ")[1]; - if (!next.equalsIgnoreCase("distinct")) - line = line.substring(0, 6) + " distinct" + line.substring(6); - } - for (int i = 0; i < line.length(); ++i) - if (line.charAt(i) == '{') - if (leftToMatch == -1) leftToMatch = 1; - else ++leftToMatch; - else if (line.charAt(i) == '}') --leftToMatch; - -// if (line.isEmpty()) break; - - if (!line.isEmpty()) - sb.append(line).append(Utility.LINE_SEPARATOR); - - if (leftToMatch == 0) break; - } - - text = preprocess(sb.toString()); - if (!text.isEmpty()) - ret.add(text); - sb.setLength(0); - } - - scanner.close(); - return ret; - } - - private static String preprocess(String text) { - int index; - text = text.trim(); - while (text.startsWith("^") || text.startsWith("#") || text.startsWith("//") || text.startsWith("@")) - if ((index = text.indexOf("\n")) != -1) - text = text.substring(index + 1); - else { - text = ""; - break; - } - return text; // text.replace(" a ", " "); - } - - private Map allRecords = new HashMap(); - private int queryCounter = 0; - - public QueryRecord create(String text, int i, int j) { -// StringBuilder queryText = new StringBuilder(); -// for (String seq : text.split("\s")) { -// if (seq.length() == 0) continue; -// if (queryText.length() != 0) queryText.append(" "); -// queryText.append(seq); -// } -// text = queryText.toString(); - text = text.replaceAll("\\s+", " ").trim(); - QueryRecord ret = allRecords.get(text); - if (ret != null) return ret; - else { - if (i == -1) { - i = ++queryCounter; - } - - ret = new QueryRecord(this, text, i, j); - allRecords.put(text, ret); - return ret; - } - } - - public QueryRecord create(String text, int i) { - return create(text, i, 0); - } - - - public void remove(String queryText) { - allRecords.remove(queryText); - } - - public void put(String text, QueryRecord queryRecord) { - allRecords.put(text, queryRecord); - } - - public QueryRecord create(String queryText) { - return create(queryText, -1, 0); - } - -} -- cgit v1.2.3