Commit fbf1151d authored by Charles Vernerey's avatar Charles Vernerey
Browse files

Update database reader to skip comments

parent c3e17efb
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ public class BinReader extends DataReader {
        try (BufferedReader reader = new BufferedReader(new FileReader(dataPath))) {
            String line;
            while ((line = reader.readLine()) != null) {
                if (skipLine(line)) continue;
                nbTransactions++;
                int currentNbItems = line.split(" ").length;
                if (nbItems == 0) {
@@ -62,6 +63,7 @@ public class BinReader extends DataReader {
            int currentTransaction = 0;
            String line;
            while ((line = reader.readLine()) != null) {
                if (skipLine(line)) continue;
                String[] lineItems = line.split(" ");
                int itemClass = -1;
                for (int i = 0; i < lineItems.length; i++) {
+2 −2
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ public class DatReader extends DataReader {
        nbTransactions = 0;
        try (BufferedReader reader = new BufferedReader(new FileReader(dataPath))) {
            while ((line = reader.readLine()) != null) {
                if (line.startsWith("#")) continue;
                if (skipLine(line)) continue;
                String[] itemsLine = line.split(" ");
                for (int i = 0; i < itemsLine.length; i++) {
                    String item = itemsLine[i];
@@ -70,7 +70,7 @@ public class DatReader extends DataReader {
            String line;
            int currentTransaction = 0;
            while ((line = reader.readLine()) != null) {
                if (line.startsWith("#")) continue;
                if (skipLine(line)) continue;
                String[] itemsLine = line.split(" ");
                int class1 = itemMap.get(Integer.parseInt(itemsLine[0])) + 1;
                maxClass = Math.max(class1, maxClass);
+4 −0
Original line number Diff line number Diff line
@@ -79,4 +79,8 @@ public abstract class DataReader {
        }
        return valueList;
    }

    protected boolean skipLine(String line) {
        return line.isEmpty() || line.charAt(0) == '#' || line.charAt(0) == '%' || line.charAt(0) == '@';
    }
}