From ad66bd5b6bfb248e131e685f631448eb7a816ef0 Mon Sep 17 00:00:00 2001 From: Laurens Rietveld Date: Sun, 17 May 2015 20:10:41 +0200 Subject: [PATCH] #4 added num distinct rdf nodes property --- .../model/statements/NumDistinctRDFNodes.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/main/java/lodanalysis/model/statements/NumDistinctRDFNodes.java diff --git a/src/main/java/lodanalysis/model/statements/NumDistinctRDFNodes.java b/src/main/java/lodanalysis/model/statements/NumDistinctRDFNodes.java new file mode 100644 index 0000000..e35c442 --- /dev/null +++ b/src/main/java/lodanalysis/model/statements/NumDistinctRDFNodes.java @@ -0,0 +1,47 @@ +package lodanalysis.model.statements; + +import java.io.File; +import java.io.IOException; + +import org.apache.commons.io.FileUtils; + +import lodanalysis.Paths; +import lodanalysis.model.CreateModel; +import lodanalysis.model.CreateModelStatement; +import lodanalysis.model.CreateModel.Namespace; + +import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; + + +public class NumDistinctRDFNodes extends CreateModelStatement { + + + public NumDistinctRDFNodes(CreateModel factory) { + super(factory); + } + + @Override + public void createDescription() throws IOException { + int bnodes = 0; + try { + bnodes = countLines(new File(dir, Paths.BNODE_COUNTS)); + } catch (Exception IOException) { + //just skip + } + int literals = 0; + try { + literals = Integer.parseInt(FileUtils.readFileToString(new File(dir, Paths.DISTINCT_LITERALS))); + } catch(Exception e) { + //just skip + } + int uris = 0; + try { + uris = Integer.parseInt(FileUtils.readFileToString(new File(dir, Paths.DISTINCT_URIS))); + } catch(Exception e) { + //just skip + } + + doc.addProperty(getProp(Namespace.LLM, "distinctRDFNodes"), Integer.toString(bnodes + literals + uris), XSDDatatype.XSDlong); + } + +}