DEFINED_WORDS = new HashSet<String>();
int associationCount = 0;
OutputStream out = new FileOutputStream(ntriplesFile);
try {
RDFWriter writer = Rio.createWriter(RDFFormat.NTRIPLES, out);
writer.startRDF();
try {
BufferedReader b = new BufferedReader(new FileReader(srConciseFile));
try {
String line;
while (null != (line = b.readLine())) {
if (0 == line.length()) {
break;
}
String subjectWord = normalizeWord(line);
// There should be an even number of lines in this file.
line = b.readLine();
if (isNormalWord(subjectWord)) {
String[] cells = line.trim().split("[|]");
int totalWeight = 0;
for (int i = 1; i < cells.length; i += 2) {
totalWeight += Integer.valueOf(cells[i]);
}
for (int i = 0; i < cells.length; i += 2) {
String objectWord = cells[i];
float weight = Float.valueOf(cells[i + 1]) / totalWeight;
associate(subjectWord, objectWord, weight, writer);
associationCount++;
}
} else {
System.err.println(subjectWord + " could not be normalized. No association created.");
}
}
} finally {
b.close();
}
} finally {
writer.endRDF();
}
} finally {
out.close();
}