public void add(Statement stmt, DataSet datastore) { RDFNode object = stmt.getObject(); if (object.isLiteral()) { if (object.asLiteral().getDatatype() != null) { if (object.asLiteral().getDatatype() instanceof XSDBaseNumericType) { integers.add(stmt, datastore); } else if (object.asLiteral().getDatatype() instanceof XSDDouble) { doubles.add(stmt, datastore); } else if (object.asLiteral().getDatatype() instanceof XSDFloat) { floats.add(stmt, datastore); } else if (object.asLiteral().getDatatype() instanceof XSDYearType) { gYears.add(stmt, datastore); } else if (object.asLiteral().getDatatype() instanceof XSDDateType) { dates.add(stmt, datastore); } else if (object.asLiteral().getDatatype() instanceof XSDYearMonthType) { gYearMonths.add(stmt, datastore); } else if (object.asLiteral().getDatatype() instanceof XSDMonthDayType) { gMonthDays.add(stmt, datastore); } else if (object.asLiteral().getDatatype() instanceof XSDTimeType) { times.add(stmt, datastore); } // else if (object.asLiteral().getDatatype() instanceof XSDboolean) // { // System.out.println(" -> XSDboolean"); // booleans.add(stmt); // System.out.println("datatype:" + // object.asLiteral().getDatatype()); // } // else if (object.asLiteral().getDatatypeURI().contains("usDollar")) // { // doubles.add(stmt); // } // else if (object.asLiteral().getDatatypeURI().contains("euro")) // { // doubles.add(stmt); // } else if (object.asLiteral().getDatatypeURI().contains("dbpedia.org/datatype")) { doubles.add(stmt, datastore); } else { unknowns.add(stmt, datastore); Evaluator.printStatement(stmt, "LiteralSwitch - unable to add an unknown data type:"); System.out.println("datatype:" + object.asLiteral().getDatatype()); System.out.println("datatype uri:" + object.asLiteral().getDatatypeURI()); } } else if (object.asLiteral().getLanguage() != null) { strings.add(stmt, datastore); } else { Evaluator.printStatement(stmt, "LiteralSwitch - unable to add an unknown literal type:"); System.out.println("data type:" + object.asLiteral().getDatatype()); System.out.println("data type uri:" + object.asLiteral().getDatatypeURI()); } } }
public void printStats() { System.out.println("Literal Results:"); System.out.println("Overall triples: " + getNumberOfLiterals()); System.out.println("Number of booleans: " + booleans.getTriples().size()); System.out.println("Number of strings: " + strings.getTriples().size()); System.out.println("Number of integers: " + integers.getTriples().size()); System.out.println("Number of doubles: " + doubles.getTriples().size()); System.out.println("Number of floats: " + floats.getTriples().size()); System.out.println("Number of dates: " + dates.getTriples().size()); System.out.println("Number of gYears: " + gYears.getTriples().size()); System.out.println("Number of gYearMonths: " + gYearMonths.getTriples().size()); System.out.println("Number of gMonthDays: " + gMonthDays.getTriples().size()); System.out.println("Number of times: " + times.getTriples().size()); System.out.println("Number of unknowns: " + unknowns.getTriples().size()); }
public Model getTriples() { Model m = ModelFactory.createDefaultModel(); m.add(unknowns.getTriples()); m.add(booleans.getTriples()); m.add(strings.getTriples()); m.add(integers.getTriples()); m.add(doubles.getTriples()); m.add(floats.getTriples()); m.add(dates.getTriples()); m.add(gYears.getTriples()); m.add(gYearMonths.getTriples()); m.add(gMonthDays.getTriples()); m.add(times.getTriples()); return m; }
public int getNumberOfLiterals() { int num = (int) unknowns.getTriples().size() + (int) booleans.getTriples().size() + (int) strings.getTriples().size() + (int) integers.getTriples().size() + (int) doubles.getTriples().size() + (int) floats.getTriples().size() + (int) dates.getTriples().size() + (int) gYears.getTriples().size() + (int) gYearMonths.getTriples().size() + (int) gMonthDays.getTriples().size() + (int) times.getTriples().size(); return num; }