Skip to content

Commit

Permalink
Comments considered in the N-Tripples input file
Browse files Browse the repository at this point in the history
  • Loading branch information
luav committed Oct 16, 2017
1 parent bb73adc commit e5f1d58
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/info/exascale/statix/CosineSimilarityMatix.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ public double[][] cosineSimilarity(String inpfname, String lblfname, String idMa
//! Parse triple in N3/quad format
//!
//! @param line - the line of text to be parsed as a triple
//! @return - array of triple (s, p, o), the provenance is omitted if any
//! @return - array of triple (s, p, o) or null, the provenance is omitted if any.
//! null is returned if the line is a comment
public static String[] parseTriple(String line) {
// Consider comments, and empty lines (at least in the end of the file)
if(line.isEmpty() || line.startsWith("#"))
return null;
String[] s = line.split(" ", 3); // RDF triple resources (parts)
// See RDF triple format details: https://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#section-triples
if(s.length < 3)
Expand Down Expand Up @@ -118,9 +122,9 @@ public static void extractGT(String n3DataSet, String clsFName, String idMapFNam
final int idNone = -1;
String line = null;
while((line = bufferedReader.readLine()) != null) {
if (line.isEmpty())
final String[] s = parseTriple(line);
if(s == null)
continue;
String[] s = parseTriple(line);
final String inst = s[0];
int id = instances.size();
if(!instances.containsKey(inst)) {
Expand Down Expand Up @@ -188,9 +192,9 @@ public HashMap<String, Integer> loadInputData(String n3DataSet, boolean filterin
) {
String line = null;
while ((line = bufferedReader.readLine()) != null) {
if (line.isEmpty())
final String[] s = parseTriple(line);
if(s == null)
continue;
String[] s = parseTriple(line);
final String inst = s[0];
final int id = instProps.size();
final String property = s[1];
Expand Down Expand Up @@ -300,9 +304,9 @@ private static TreeMap<String, InstPropsStat> loadInstanceProperties(String n3Da

try(Stream<String> stream = Files.lines(Paths.get(n3DataSet))) {
stream.forEach(line -> {
if (line.isEmpty())
final String[] s = parseTriple(line);
if(s == null)
return;
String[] s = parseTriple(line);
final String prop = s[1];
final String instance = s[0];
InstPropsStat propstat = instsSProps.get(instance);
Expand Down

0 comments on commit e5f1d58

Please sign in to comment.