Fixed bug in triple loader transposer: properties didn't get asserted before.

Made triple loader transposer index its output variables.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@106 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-02-19 07:05:09 +00:00
parent 5264c829ae
commit bc412b99ea

View File

@ -1,7 +1,9 @@
package com.metaweb.gridworks.protograph.transpose;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.json.JSONObject;
@ -19,6 +21,7 @@ import com.metaweb.gridworks.protograph.ValueNode;
public class TripleLoaderTransposedNodeFactory implements TransposedNodeFactory {
protected List<WritingTransposedNode> rootNodes = new LinkedList<WritingTransposedNode>();
protected StringBuffer stringBuffer;
protected Map<String, Long> varPool = new HashMap<String, Long>();
public String getLoad() {
stringBuffer = new StringBuffer();
@ -112,12 +115,22 @@ public class TripleLoaderTransposedNodeFactory implements TransposedNodeFactory
cell.recon.match != null) {
id = cell.recon.match.topicID;
} else {
id = "$" + node.columnName.replaceAll("\\W", "_");
long var = 0;
if (varPool.containsKey(node.columnName)) {
var = varPool.get(node.columnName);
}
varPool.put(node.columnName, var + 1);
id = "$" + node.columnName.replaceAll("\\W+", "_") + "_" + var;
writeLine("{ 's' : '" + id + "', 'p' : 'type', 'o' : '" + node.type.id + "' }");
writeLine("{ 's' : '" + id + "', 'p' : 'name', 'o' : " + JSONObject.quote(cell.value.toString()) + " }");
}
if (subject != null) {
writeLine(subject, predicate, id);
}
writeChildren(id);
return JSONObject.quote(id);