Fixed bug in protograph transposer in which cells in subsequent rows of a tree-shaped record (with blank context cells) are not processed. This bug was introduced when we started to allow a protograph node to correspond to more than one column.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@1621 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
460d01230b
commit
d85ae8c28c
@ -132,7 +132,6 @@ public class Transposer {
|
|||||||
) {
|
) {
|
||||||
List<TransposedNode> tnodes = new LinkedList<TransposedNode>();
|
List<TransposedNode> tnodes = new LinkedList<TransposedNode>();
|
||||||
|
|
||||||
TransposedNode parentNode = context.parent == null ? null : context.parent.transposedNode;
|
|
||||||
Link link = context.parent == null ? null : context.link;
|
Link link = context.parent == null ? null : context.link;
|
||||||
|
|
||||||
if (node instanceof CellNode) {
|
if (node instanceof CellNode) {
|
||||||
@ -144,6 +143,7 @@ public class Transposer {
|
|||||||
|
|
||||||
Cell cell = row.getCell(cellIndex);
|
Cell cell = row.getCell(cellIndex);
|
||||||
if (cell != null && ExpressionUtils.isNonBlankData(cell.value)) {
|
if (cell != null && ExpressionUtils.isNonBlankData(cell.value)) {
|
||||||
|
System.err.println("row " + rowIndex + " non-blank column " + columnName);
|
||||||
if (node2 instanceof CellTopicNode &&
|
if (node2 instanceof CellTopicNode &&
|
||||||
(cell.recon == null || cell.recon.judgment == Judgment.None)) {
|
(cell.recon == null || cell.recon.judgment == Judgment.None)) {
|
||||||
return;
|
return;
|
||||||
@ -154,42 +154,95 @@ public class Transposer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tnodes.add(nodeFactory.transposeCellNode(
|
if (context.parent == null) {
|
||||||
parentNode,
|
tnodes.add(nodeFactory.transposeCellNode(
|
||||||
link,
|
null,
|
||||||
node2,
|
link,
|
||||||
rowIndex,
|
node2,
|
||||||
cellIndex,
|
rowIndex,
|
||||||
cell
|
cellIndex,
|
||||||
));
|
cell
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
for (TransposedNode parentNode : context.parent.transposedNodes) {
|
||||||
|
tnodes.add(nodeFactory.transposeCellNode(
|
||||||
|
parentNode,
|
||||||
|
link,
|
||||||
|
node2,
|
||||||
|
rowIndex,
|
||||||
|
cellIndex,
|
||||||
|
cell
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.err.println("row " + rowIndex + " blank column " + columnName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (node instanceof AnonymousNode) {
|
if (node instanceof AnonymousNode) {
|
||||||
tnodes.add(nodeFactory.transposeAnonymousNode(
|
if (context.parent == null) {
|
||||||
parentNode,
|
tnodes.add(nodeFactory.transposeAnonymousNode(
|
||||||
link,
|
null,
|
||||||
(AnonymousNode) node,
|
link,
|
||||||
rowIndex
|
(AnonymousNode) node,
|
||||||
));
|
rowIndex
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
for (TransposedNode parentNode : context.parent.transposedNodes) {
|
||||||
|
tnodes.add(nodeFactory.transposeAnonymousNode(
|
||||||
|
parentNode,
|
||||||
|
link,
|
||||||
|
(AnonymousNode) node,
|
||||||
|
rowIndex
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (node instanceof FreebaseTopicNode) {
|
} else if (node instanceof FreebaseTopicNode) {
|
||||||
tnodes.add(nodeFactory.transposeTopicNode(
|
if (context.parent == null) {
|
||||||
parentNode,
|
tnodes.add(nodeFactory.transposeTopicNode(
|
||||||
link,
|
null,
|
||||||
(FreebaseTopicNode) node,
|
link,
|
||||||
rowIndex
|
(FreebaseTopicNode) node,
|
||||||
));
|
rowIndex
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
for (TransposedNode parentNode : context.parent.transposedNodes) {
|
||||||
|
tnodes.add(nodeFactory.transposeTopicNode(
|
||||||
|
parentNode,
|
||||||
|
link,
|
||||||
|
(FreebaseTopicNode) node,
|
||||||
|
rowIndex
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (node instanceof ValueNode) {
|
} else if (node instanceof ValueNode) {
|
||||||
tnodes.add(nodeFactory.transposeValueNode(
|
if (context.parent == null) {
|
||||||
parentNode,
|
tnodes.add(nodeFactory.transposeValueNode(
|
||||||
link,
|
null,
|
||||||
(ValueNode) node,
|
link,
|
||||||
rowIndex
|
(ValueNode) node,
|
||||||
));
|
rowIndex
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
for (TransposedNode parentNode : context.parent.transposedNodes) {
|
||||||
|
tnodes.add(nodeFactory.transposeValueNode(
|
||||||
|
parentNode,
|
||||||
|
link,
|
||||||
|
(ValueNode) node,
|
||||||
|
rowIndex
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tnodes.size() > 0) {
|
||||||
|
context.transposedNodes.clear();
|
||||||
|
context.transposedNodes.addAll(tnodes);
|
||||||
|
}
|
||||||
|
|
||||||
if (node instanceof NodeWithLinks) {
|
if (node instanceof NodeWithLinks) {
|
||||||
NodeWithLinks node2 = (NodeWithLinks) node;
|
NodeWithLinks node2 = (NodeWithLinks) node;
|
||||||
int linkCount = node2.getLinkCount();
|
int linkCount = node2.getLinkCount();
|
||||||
@ -197,32 +250,28 @@ public class Transposer {
|
|||||||
for (int i = 0; i < linkCount; i++) {
|
for (int i = 0; i < linkCount; i++) {
|
||||||
Link link2 = node2.getLink(i);
|
Link link2 = node2.getLink(i);
|
||||||
if (link2.condition == null || link2.condition.test(project, rowIndex, row)) {
|
if (link2.condition == null || link2.condition.test(project, rowIndex, row)) {
|
||||||
for (TransposedNode tnode : tnodes) {
|
System.err.println(" row " + rowIndex + " descend " + link2.property.id);
|
||||||
context.transposedNode = tnode;
|
descend(
|
||||||
context.nullifySubContextNodes();
|
project,
|
||||||
|
protograph,
|
||||||
descend(
|
nodeFactory,
|
||||||
project,
|
rowIndex,
|
||||||
protograph,
|
row,
|
||||||
nodeFactory,
|
link2.getTarget(),
|
||||||
rowIndex,
|
context.subContexts.get(i)
|
||||||
row,
|
);
|
||||||
link2.getTarget(),
|
|
||||||
context.subContexts.get(i)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Context {
|
static class Context {
|
||||||
TransposedNode transposedNode;
|
List<TransposedNode> transposedNodes = new LinkedList<TransposedNode>();
|
||||||
List<Context> subContexts;
|
List<Context> subContexts;
|
||||||
Context parent;
|
Context parent;
|
||||||
Link link;
|
Link link;
|
||||||
int count;
|
int count;
|
||||||
int limit;
|
int limit;
|
||||||
|
|
||||||
Context(Node node, Context parent, Link link, int limit) {
|
Context(Node node, Context parent, Link link, int limit) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
@ -246,7 +295,7 @@ public class Transposer {
|
|||||||
public void nullifySubContextNodes() {
|
public void nullifySubContextNodes() {
|
||||||
if (subContexts != null) {
|
if (subContexts != null) {
|
||||||
for (Context context : subContexts) {
|
for (Context context : subContexts) {
|
||||||
context.transposedNode = null;
|
context.transposedNodes.clear();
|
||||||
context.nullifySubContextNodes();
|
context.nullifySubContextNodes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user