diff options
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/util/TurtleHelper.java')
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/util/TurtleHelper.java | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/util/TurtleHelper.java b/src/uk/ac/ox/cs/pagoda/util/TurtleHelper.java deleted file mode 100644 index 6887b9f..0000000 --- a/src/uk/ac/ox/cs/pagoda/util/TurtleHelper.java +++ /dev/null | |||
| @@ -1,56 +0,0 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.util; | ||
| 2 | |||
| 3 | import java.io.*; | ||
| 4 | |||
| 5 | public class TurtleHelper { | ||
| 6 | |||
| 7 | public static void simplify(String tempFile, String outputPath) throws IOException { | ||
| 8 | BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(tempFile))); | ||
| 9 | BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputPath))); | ||
| 10 | |||
| 11 | String line, sub = null, pred = null, obj = null; | ||
| 12 | char lastSymbol = '.', symbol; | ||
| 13 | String[] seg; | ||
| 14 | while ((line = reader.readLine()) != null) { | ||
| 15 | if (line.trim().isEmpty() || line.startsWith("#") || line.startsWith("@base")) | ||
| 16 | continue; | ||
| 17 | |||
| 18 | if (line.startsWith("@")) { | ||
| 19 | writer.write(line); | ||
| 20 | writer.newLine(); | ||
| 21 | continue; | ||
| 22 | } | ||
| 23 | |||
| 24 | |||
| 25 | symbol = line.charAt(line.length() - 1); | ||
| 26 | |||
| 27 | if (lastSymbol == '.') { | ||
| 28 | seg = line.split(" "); | ||
| 29 | sub = seg[0]; | ||
| 30 | pred = seg[1]; | ||
| 31 | obj = seg[2]; | ||
| 32 | } | ||
| 33 | else if (lastSymbol == ';') { | ||
| 34 | line = line.substring(sub.length() + 1); | ||
| 35 | seg = line.split(" "); | ||
| 36 | pred = seg[0]; | ||
| 37 | obj = seg[1]; | ||
| 38 | } | ||
| 39 | else if (lastSymbol == ',') { | ||
| 40 | line = line.substring(sub.length() + pred.length() + 2); | ||
| 41 | obj = line.substring(0, line.lastIndexOf(' ')); | ||
| 42 | } | ||
| 43 | else Utility.logError("ERROR"); | ||
| 44 | |||
| 45 | lastSymbol = symbol; | ||
| 46 | if (pred.equals("rdf:type") && obj.startsWith("owl:")) | ||
| 47 | continue; | ||
| 48 | |||
| 49 | writer.write(sub + " " + pred + " " + obj + " .\n"); | ||
| 50 | } | ||
| 51 | |||
| 52 | reader.close(); | ||
| 53 | writer.close(); | ||
| 54 | } | ||
| 55 | |||
| 56 | } | ||
