Make similar cell judgments an abstract operation.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@120 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-02-22 20:25:45 +00:00
parent c98a8ad552
commit e4b01cb36c
10 changed files with 322 additions and 302 deletions

View File

@ -18,6 +18,7 @@ import com.metaweb.gridworks.model.Column;
import com.metaweb.gridworks.model.Project; import com.metaweb.gridworks.model.Project;
import com.metaweb.gridworks.model.Recon; import com.metaweb.gridworks.model.Recon;
import com.metaweb.gridworks.model.ReconCandidate; import com.metaweb.gridworks.model.ReconCandidate;
import com.metaweb.gridworks.model.Recon.Judgment;
import com.metaweb.gridworks.model.changes.CellChange; import com.metaweb.gridworks.model.changes.CellChange;
import com.metaweb.gridworks.process.QuickHistoryEntryProcess; import com.metaweb.gridworks.process.QuickHistoryEntryProcess;
@ -31,37 +32,31 @@ public class ReconJudgeOneCellCommand extends Command {
int rowIndex = Integer.parseInt(request.getParameter("row")); int rowIndex = Integer.parseInt(request.getParameter("row"));
int cellIndex = Integer.parseInt(request.getParameter("cell")); int cellIndex = Integer.parseInt(request.getParameter("cell"));
String judgment = request.getParameter("judgment"); Judgment judgment = Recon.stringToJudgment(request.getParameter("judgment"));
JudgeOneCellProcess process = null; ReconCandidate match = null;
String topicID = request.getParameter("topicID");
if (topicID != null) {
String scoreString = request.getParameter("score");
if (judgment != null) { match = new ReconCandidate(
process = new JudgeOneCellProcess( topicID,
project,
"Judge one cell's recon result",
judgment,
rowIndex,
cellIndex,
request.getParameter("candidate")
);
} else {
ReconCandidate match = new ReconCandidate(
request.getParameter("topicID"),
request.getParameter("topicGUID"), request.getParameter("topicGUID"),
request.getParameter("topicName"), request.getParameter("topicName"),
request.getParameter("types").split(","), request.getParameter("types").split(","),
100 scoreString != null ? Double.parseDouble(scoreString) : 100
);
process = new JudgeOneCellProcess(
project,
"Judge one cell's recon result",
rowIndex,
cellIndex,
match
); );
} }
JudgeOneCellProcess process = new JudgeOneCellProcess(
project,
"Judge one cell's recon result",
judgment,
rowIndex,
cellIndex,
match
);
boolean done = project.processManager.queueProcess(process); boolean done = project.processManager.queueProcess(process);
if (done) { if (done) {
JSONWriter writer = new JSONWriter(response.getWriter()); JSONWriter writer = new JSONWriter(response.getWriter());
@ -80,27 +75,24 @@ public class ReconJudgeOneCellCommand extends Command {
protected class JudgeOneCellProcess extends QuickHistoryEntryProcess { protected class JudgeOneCellProcess extends QuickHistoryEntryProcess {
final int rowIndex; final int rowIndex;
final int cellIndex; final int cellIndex;
final String judgment; final Judgment judgment;
final String candidateID;
final ReconCandidate match; final ReconCandidate match;
Cell newCell; Cell newCell;
JudgeOneCellProcess(Project project, String briefDescription, String judgment, int rowIndex, int cellIndex, String candidateID) { JudgeOneCellProcess(
Project project,
String briefDescription,
Judgment judgment,
int rowIndex,
int cellIndex,
ReconCandidate match
) {
super(project, briefDescription); super(project, briefDescription);
this.rowIndex = rowIndex;
this.cellIndex = cellIndex;
this.judgment = judgment;
this.candidateID = candidateID;
this.match = null;
}
JudgeOneCellProcess(Project project, String briefDescription, int rowIndex, int cellIndex, ReconCandidate match) { this.judgment = judgment;
super(project, briefDescription);
this.rowIndex = rowIndex; this.rowIndex = rowIndex;
this.cellIndex = cellIndex; this.cellIndex = cellIndex;
this.judgment = null;
this.candidateID = null;
this.match = match; this.match = match;
} }
@ -126,45 +118,20 @@ public class ReconJudgeOneCellCommand extends Command {
", containing \"" + cell.value + "\""; ", containing \"" + cell.value + "\"";
String description = null; String description = null;
if (judgment == Judgment.None) {
if (match != null) { newCell.recon.judgment = Recon.Judgment.None;
newCell.recon.match = null;
description = "Discard recon judgment for " + cellDescription;
} else if (judgment == Judgment.New) {
newCell.recon.judgment = Recon.Judgment.New;
description = "Mark to create new topic for " + cellDescription;
} else {
newCell.recon.judgment = Recon.Judgment.Matched; newCell.recon.judgment = Recon.Judgment.Matched;
newCell.recon.match = this.match; newCell.recon.match = this.match;
description = "Match " + this.match.topicName + description = "Match " + this.match.topicName +
" (" + match.topicID + ") to " + " (" + match.topicID + ") to " +
cellDescription; cellDescription;
} else {
if ("match".equals(judgment)) {
ReconCandidate match = null;
if (cell.recon != null) {
for (ReconCandidate c : cell.recon.candidates) {
if (candidateID.equals(c.topicID)) {
match = c;
break;
}
}
}
if (match == null) {
throw new Exception("No such recon candidate");
}
newCell.recon.judgment = Recon.Judgment.Matched;
newCell.recon.match = match;
description = "Match " + match.topicName +
" (" + match.topicID + ") to " +
cellDescription;
} else if ("new".equals(judgment)) {
newCell.recon.judgment = Recon.Judgment.New;
description = "Mark to create new topic for " + cellDescription;
} else if ("discard".equals(judgment)) {
newCell.recon.judgment = Recon.Judgment.None;
newCell.recon.match = null;
description = "Discard recon judgment for " + cellDescription;
}
} }
Change change = new CellChange(rowIndex, cellIndex, cell, newCell); Change change = new CellChange(rowIndex, cellIndex, cell, newCell);

View File

@ -1,220 +1,44 @@
package com.metaweb.gridworks.commands.recon; package com.metaweb.gridworks.commands.recon;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONWriter; import org.json.JSONObject;
import com.metaweb.gridworks.browsing.Engine; import com.metaweb.gridworks.commands.EngineDependentCommand;
import com.metaweb.gridworks.browsing.FilteredRows; import com.metaweb.gridworks.model.AbstractOperation;
import com.metaweb.gridworks.browsing.RowVisitor;
import com.metaweb.gridworks.commands.Command;
import com.metaweb.gridworks.expr.ExpressionUtils;
import com.metaweb.gridworks.history.HistoryEntry;
import com.metaweb.gridworks.model.Cell;
import com.metaweb.gridworks.model.Column;
import com.metaweb.gridworks.model.Project;
import com.metaweb.gridworks.model.Recon;
import com.metaweb.gridworks.model.ReconCandidate; import com.metaweb.gridworks.model.ReconCandidate;
import com.metaweb.gridworks.model.Row; import com.metaweb.gridworks.operations.ReconJudgeSimilarCellsOperation;
import com.metaweb.gridworks.model.changes.CellChange;
import com.metaweb.gridworks.model.changes.MassCellChange; public class ReconJudgeSimilarCellsCommand extends EngineDependentCommand {
import com.metaweb.gridworks.process.QuickHistoryEntryProcess;
public class ReconJudgeSimilarCellsCommand extends Command {
@Override @Override
public void doPost(HttpServletRequest request, HttpServletResponse response) protected AbstractOperation createOperation(
throws ServletException, IOException { HttpServletRequest request, JSONObject engineConfig) throws Exception {
try { String columnName = request.getParameter("columnName");
Project project = getProject(request); String similarValue = request.getParameter("similarValue");
Engine engine = getEngine(request, project); String judgment = request.getParameter("judgment");
int rowIndex = Integer.parseInt(request.getParameter("row")); ReconCandidate match = null;
int cellIndex = Integer.parseInt(request.getParameter("cell")); String topicID = request.getParameter("topicID");
String judgment = request.getParameter("judgment"); if (topicID != null) {
String scoreString = request.getParameter("score");
JudgeSimilarCellsProcess process = null; match = new ReconCandidate(
topicID,
if (judgment != null) { request.getParameter("topicGUID"),
process = new JudgeSimilarCellsProcess( request.getParameter("topicName"),
project, request.getParameter("types").split(","),
engine, scoreString != null ? Double.parseDouble(scoreString) : 100
"Judge one cell's recon result", );
judgment,
rowIndex,
cellIndex,
request.getParameter("candidate")
);
} else {
ReconCandidate match = new ReconCandidate(
request.getParameter("topicID"),
request.getParameter("topicGUID"),
request.getParameter("topicName"),
request.getParameter("types").split(","),
100
);
process = new JudgeSimilarCellsProcess(
project,
engine,
"Judge one cell's recon result",
rowIndex,
cellIndex,
match
);
}
boolean done = project.processManager.queueProcess(process);
if (done) {
JSONWriter writer = new JSONWriter(response.getWriter());
writer.object();
writer.key("code"); writer.value("ok");
writer.endObject();
} else {
respond(response, "{ \"code\" : \"pending\" }");
}
} catch (Exception e) {
respondException(response, e);
}
}
protected class JudgeSimilarCellsProcess extends QuickHistoryEntryProcess {
final Engine engine;
final int rowIndex;
final int cellIndex;
final String judgment;
final String candidateID;
final ReconCandidate match;
JudgeSimilarCellsProcess(Project project, Engine engine, String briefDescription, String judgment, int rowIndex, int cellIndex, String candidateID) {
super(project, briefDescription);
this.engine = engine;
this.rowIndex = rowIndex;
this.cellIndex = cellIndex;
this.judgment = judgment;
this.candidateID = candidateID;
this.match = null;
} }
JudgeSimilarCellsProcess(Project project, Engine engine, String briefDescription, int rowIndex, int cellIndex, ReconCandidate match) { return new ReconJudgeSimilarCellsOperation(
super(project, briefDescription); engineConfig,
this.engine = engine; columnName,
this.rowIndex = rowIndex; similarValue,
this.cellIndex = cellIndex; judgment,
this.judgment = null; match
this.candidateID = null; );
this.match = match;
}
protected HistoryEntry createHistoryEntry() throws Exception {
Cell cell = _project.rows.get(rowIndex).getCell(cellIndex);
if (cell == null || ExpressionUtils.isBlank(cell.value)) {
throw new Exception("Cell is blank");
}
Column column = _project.columnModel.getColumnByCellIndex(cellIndex);
if (column == null) {
throw new Exception("No such column");
}
List<CellChange> cellChanges = new ArrayList<CellChange>(_project.rows.size());
String similarValue = cell.value.toString();
RowVisitor rowVisitor = new RowVisitor() {
List<CellChange> cellChanges;
String similarValue;
public RowVisitor init(List<CellChange> cellChanges, String similarValue) {
this.cellChanges = cellChanges;
this.similarValue = similarValue;
return this;
}
public boolean visit(Project project, int rowIndex, Row row, boolean contextual) {
Cell cell = row.getCell(cellIndex);
if (cell != null && !ExpressionUtils.isBlank(cell.value) && similarValue.equals(cell.value)) {
Cell newCell = new Cell(
cell.value,
cell.recon == null ? new Recon() : cell.recon.dup()
);
if (match != null) {
newCell.recon.judgment = Recon.Judgment.Matched;
newCell.recon.match = match;
} else {
if ("match".equals(judgment)) {
ReconCandidate match = null;
if (cell.recon != null) {
for (ReconCandidate c : cell.recon.candidates) {
if (candidateID.equals(c.topicID)) {
match = c;
break;
}
}
}
if (match == null) {
return false;
}
newCell.recon.judgment = Recon.Judgment.Matched;
newCell.recon.match = match;
} else if ("new".equals(judgment)) {
newCell.recon.judgment = Recon.Judgment.New;
} else if ("discard".equals(judgment)) {
newCell.recon.judgment = Recon.Judgment.None;
newCell.recon.match = null;
}
}
CellChange cellChange = new CellChange(rowIndex, cellIndex, cell, newCell);
cellChanges.add(cellChange);
}
return false;
}
}.init(cellChanges, similarValue);
FilteredRows filteredRows = engine.getAllFilteredRows(false);
filteredRows.accept(_project, rowVisitor);
String description = null;
if (match != null) {
description = "Match " +
cellChanges.size() + " cell(s) in column " +
column.getHeaderLabel() + " containing " +
similarValue + " to topic " +
match.topicName + " (" +
match.topicID + ")";
} else {
if ("match".equals(judgment)) {
description = "Match " +
cellChanges.size() + " cell(s) in column " +
column.getHeaderLabel() + " containing " +
similarValue + " to topic " +
candidateID;
} else if ("new".equals(judgment)) {
description = "Mark to create new topic for " +
cellChanges.size() + " cell(s) in column " +
column.getHeaderLabel() + " containing " +
similarValue;
} else if ("discard".equals(judgment)) {
description = "Discard recon judgments for " +
cellChanges.size() + " cell(s) in column " +
column.getHeaderLabel() + " containing " +
similarValue;
}
}
MassCellChange massCellChange = new MassCellChange(
cellChanges, column.getHeaderLabel(), false);
return new HistoryEntry(_project, description, null, massCellChange);
}
} }
} }

View File

@ -22,6 +22,27 @@ public class Recon implements Serializable, HasFields, Jsonizable {
New New
} }
static public String judgmentToString(Judgment judgment) {
if (judgment == Judgment.Matched) {
return "matched";
} else if (judgment == Judgment.New) {
return "new";
} else {
return "none";
}
}
static public Judgment stringToJudgment(String s) {
if ("matched".equals(s)) {
return Judgment.Matched;
} else if ("new".equals(s)) {
return Judgment.New;
} else {
return Judgment.None;
}
}
static public int Feature_typeMatch = 0; static public int Feature_typeMatch = 0;
static public int Feature_nameMatch = 1; static public int Feature_nameMatch = 1;
static public int Feature_nameLevenshtein = 2; static public int Feature_nameLevenshtein = 2;
@ -94,13 +115,7 @@ public class Recon implements Serializable, HasFields, Jsonizable {
} }
protected String judgmentToString() { protected String judgmentToString() {
if (judgment == Judgment.Matched) { return judgmentToString(judgment);
return "matched";
} else if (judgment == Judgment.New) {
return "new";
} else {
return "none";
}
} }
public class Features implements HasFields { public class Features implements HasFields {

View File

@ -46,17 +46,14 @@ public class ReconCandidate implements Serializable, HasFields, Jsonizable {
writer.object(); writer.object();
writer.key("id"); writer.value(topicID); writer.key("id"); writer.value(topicID);
//writer.key("guid"); writer.value(topicGUID); writer.key("guid"); writer.value(topicGUID);
writer.key("name"); writer.value(topicName); writer.key("name"); writer.value(topicName);
writer.key("score"); writer.value(score); writer.key("score"); writer.value(score);
/*
writer.key("types"); writer.array(); writer.key("types"); writer.array();
for (String typeID : typeIDs) { for (String typeID : typeIDs) {
writer.value(typeID); writer.value(typeID);
} }
writer.endArray(); writer.endArray();
*/
writer.endObject(); writer.endObject();
} }

View File

@ -23,6 +23,7 @@ public abstract class OperationRegistry {
register("recon-match-best-candidates", ReconMatchBestCandidatesOperation.class); register("recon-match-best-candidates", ReconMatchBestCandidatesOperation.class);
register("recon-discard-judgments", ReconDiscardJudgmentsOperation.class); register("recon-discard-judgments", ReconDiscardJudgmentsOperation.class);
register("recon-match-specific-topic-to-cells", ReconMatchSpecificTopicOperation.class); register("recon-match-specific-topic-to-cells", ReconMatchSpecificTopicOperation.class);
register("recon-judge-similar-cells", ReconJudgeSimilarCellsOperation.class);
register("multivalued-cell-join", MultiValuedCellJoinOperation.class); register("multivalued-cell-join", MultiValuedCellJoinOperation.class);
register("multivalued-cell-split", MultiValuedCellSplitOperation.class); register("multivalued-cell-split", MultiValuedCellSplitOperation.class);

View File

@ -0,0 +1,185 @@
package com.metaweb.gridworks.operations;
import java.util.List;
import java.util.Properties;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONWriter;
import com.metaweb.gridworks.browsing.RowVisitor;
import com.metaweb.gridworks.expr.ExpressionUtils;
import com.metaweb.gridworks.model.AbstractOperation;
import com.metaweb.gridworks.model.Cell;
import com.metaweb.gridworks.model.Column;
import com.metaweb.gridworks.model.Project;
import com.metaweb.gridworks.model.Recon;
import com.metaweb.gridworks.model.ReconCandidate;
import com.metaweb.gridworks.model.Row;
import com.metaweb.gridworks.model.Recon.Judgment;
import com.metaweb.gridworks.model.changes.CellChange;
public class ReconJudgeSimilarCellsOperation extends EngineDependentMassCellOperation {
private static final long serialVersionUID = -5205694623711144436L;
final protected String _similarValue;
final protected Judgment _judgment;
final protected ReconCandidate _match;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
JSONObject engineConfig = obj.getJSONObject("engineConfig");
ReconCandidate match = null;
if (obj.has("match")) {
JSONObject matchObj = obj.getJSONObject("match");
JSONArray types = matchObj.getJSONArray("types");
String[] typeIDs = new String[types.length()];
for (int i = 0; i < typeIDs.length; i++) {
typeIDs[i] = types.getString(i);
}
match = new ReconCandidate(
matchObj.getString("id"),
matchObj.getString("guid"),
matchObj.getString("name"),
typeIDs,
matchObj.getDouble("score")
);
}
Judgment judgment = Judgment.None;
if (obj.has("judgment")) {
judgment = Recon.stringToJudgment(obj.getString("judgment"));
}
return new ReconJudgeSimilarCellsOperation(
engineConfig,
obj.getString("columnName"),
obj.getString("similarValue"),
judgment,
match
);
}
public ReconJudgeSimilarCellsOperation(
JSONObject engineConfig,
String columnName,
String similarValue,
Judgment judgment,
ReconCandidate match
) {
super(engineConfig, columnName, false);
this._similarValue = similarValue;
this._judgment = judgment;
this._match = match;
}
public ReconJudgeSimilarCellsOperation(
JSONObject engineConfig,
String columnName,
String similarValue,
String judgmentString,
ReconCandidate match
) {
super(engineConfig, columnName, false);
this._similarValue = similarValue;
this._judgment = Recon.stringToJudgment(judgmentString);
this._match = match;
}
public void write(JSONWriter writer, Properties options)
throws JSONException {
writer.object();
writer.key("op"); writer.value(OperationRegistry.s_opClassToName.get(this.getClass()));
writer.key("description"); writer.value(getBriefDescription());
writer.key("engineConfig"); writer.value(getEngineConfig());
writer.key("columnName"); writer.value(_columnName);
writer.key("similarValue"); writer.value(_similarValue);
writer.key("judgment"); writer.value(Recon.judgmentToString(_judgment));
if (_match != null) {
writer.key("match"); _match.write(writer, options);
}
writer.endObject();
}
protected String getBriefDescription() {
if (_judgment == Judgment.None) {
return "Discard recon judgments for cells containing \"" +
_similarValue + "\" in column " + _columnName;
} else if (_judgment == Judgment.New) {
return "Mark to create new topics for cells containing \"" +
_similarValue + "\" in column " + _columnName;
} else if (_judgment == Judgment.Matched) {
return "Match topic " +
_match.topicName + " (" +
_match.topicID + ") for cells containing \"" +
_similarValue + "\" in column " + _columnName;
}
throw new InternalError("Can't get here");
}
protected String createDescription(Column column,
List<CellChange> cellChanges) {
if (_judgment == Judgment.None) {
return "Discard recon judgments for " + cellChanges.size() + " cells containing \"" +
_similarValue + "\" in column " + _columnName;
} else if (_judgment == Judgment.New) {
return "Mark to create new topics for " + cellChanges.size() + " cells containing \"" +
_similarValue + "\" in column " + _columnName;
} else if (_judgment == Judgment.Matched) {
return "Match topic " +
_match.topicName + " (" +
_match.topicID + ") for " +
cellChanges.size() + " cells containing \"" +
_similarValue + "\" in column " + _columnName;
}
throw new InternalError("Can't get here");
}
protected RowVisitor createRowVisitor(Project project, List<CellChange> cellChanges) throws Exception {
Column column = project.columnModel.getColumnByName(_columnName);
return new RowVisitor() {
int _cellIndex;
List<CellChange> _cellChanges;
public RowVisitor init(int cellIndex, List<CellChange> cellChanges) {
_cellIndex = cellIndex;
_cellChanges = cellChanges;
return this;
}
public boolean visit(Project project, int rowIndex, Row row, boolean contextual) {
Cell cell = row.getCell(_cellIndex);
if (cell != null &&
!ExpressionUtils.isBlank(cell.value) &&
_similarValue.equals(cell.value)) {
Cell newCell = new Cell(
cell.value,
cell.recon == null ? new Recon() : cell.recon.dup()
);
if (_judgment == Judgment.Matched) {
newCell.recon.judgment = Recon.Judgment.Matched;
newCell.recon.match = _match;
} else if (_judgment == Judgment.New) {
newCell.recon.judgment = Recon.Judgment.New;
} else if (_judgment == Judgment.None) {
newCell.recon.judgment = Recon.Judgment.None;
newCell.recon.match = null;
}
CellChange cellChange = new CellChange(rowIndex, _cellIndex, cell, newCell);
_cellChanges.add(cellChange);
}
return false;
}
}.init(column.getCellIndex(), cellChanges);
}
}

View File

@ -62,3 +62,14 @@ function reinitializeProjectData(f) {
f f
); );
} }
function cellIndexToColumn(index) {
var columns = theProject.columnModel.columns;
for (var i = 0; i < columns.length; i++) {
var column = columns[i];
if (column.cellIndex == index) {
return column;
}
}
return null;
}

View File

@ -10,10 +10,13 @@ BrowsingEngine.prototype._initializeUI = function() {
var container = this._div.empty(); var container = this._div.empty();
}; };
BrowsingEngine.prototype.getJSON = function() { BrowsingEngine.prototype.getJSON = function(keepUnrestrictedFacets) {
var a = { facets: [] }; var a = { facets: [] };
for (var i = 0; i < this._facets.length; i++) { for (var i = 0; i < this._facets.length; i++) {
a.facets.push(this._facets[i].facet.getJSON()); var facet = this._facets[i];
if (keepUnrestrictedFacets || facet.facet.hasSelection()) {
a.facets.push(this._facets[i].facet.getJSON());
}
} }
return a; return a;
}; };
@ -57,7 +60,7 @@ BrowsingEngine.prototype.update = function() {
$.post( $.post(
"/command/compute-facets?" + $.param({ project: theProject.id }), "/command/compute-facets?" + $.param({ project: theProject.id }),
{ engine: JSON.stringify(ui.browsingEngine.getJSON()) }, { engine: JSON.stringify(ui.browsingEngine.getJSON(true)) },
function(data) { function(data) {
var facetData = data.facets; var facetData = data.facets;

View File

@ -62,14 +62,14 @@ DataTableCellUI.prototype._render = function() {
.addClass("data-table-recon-match-similar") .addClass("data-table-recon-match-similar")
.attr("title", "Match this topic to this cell and other cells with the same content") .attr("title", "Match this topic to this cell and other cells with the same content")
.appendTo(li).click(function(evt) { .appendTo(li).click(function(evt) {
self._doMatchTopicToSimilarCells(candidate.id); self._doMatchTopicToSimilarCells(candidate);
}); });
$('<a href="javascript:{}">&nbsp;</a>') $('<a href="javascript:{}">&nbsp;</a>')
.addClass("data-table-recon-match") .addClass("data-table-recon-match")
.attr("title", "Match this topic to this cell") .attr("title", "Match this topic to this cell")
.appendTo(li).click(function(evt) { .appendTo(li).click(function(evt) {
self._doMatchTopicToOneCell(candidate.id); self._doMatchTopicToOneCell(candidate);
}); });
$('<a></a>') $('<a></a>')
@ -122,7 +122,7 @@ DataTableCellUI.prototype._render = function() {
}; };
DataTableCellUI.prototype._doRematch = function() { DataTableCellUI.prototype._doRematch = function() {
this._doJudgment("discard"); this._doJudgment("none");
}; };
DataTableCellUI.prototype._doMatchNewTopicToOneCell = function() { DataTableCellUI.prototype._doMatchNewTopicToOneCell = function() {
@ -133,12 +133,24 @@ DataTableCellUI.prototype._doMatchNewTopicToSimilarCells = function() {
this._doJudgmentForSimilarCells("new"); this._doJudgmentForSimilarCells("new");
}; };
DataTableCellUI.prototype._doMatchTopicToOneCell = function(candidateID) { DataTableCellUI.prototype._doMatchTopicToOneCell = function(candidate) {
this._doJudgment("match", { candidate : candidateID }); this._doJudgment("matched", {
topicID : candidate.id,
topicGUID: candidate.guid,
topicName: candidate.name,
score: candidate.score,
types: candidate.types.join(",")
});
}; };
DataTableCellUI.prototype._doMatchTopicToSimilarCells = function(candidateID) { DataTableCellUI.prototype._doMatchTopicToSimilarCells = function(candidate) {
this._doJudgmentForSimilarCells("match", { candidate : candidateID }); this._doJudgmentForSimilarCells("matched", {
topicID : candidate.id,
topicGUID: candidate.guid,
topicName: candidate.name,
score: candidate.score,
types: candidate.types.join(",")
});
}; };
DataTableCellUI.prototype._doJudgment = function(judgment, params) { DataTableCellUI.prototype._doJudgment = function(judgment, params) {
@ -151,8 +163,8 @@ DataTableCellUI.prototype._doJudgment = function(judgment, params) {
DataTableCellUI.prototype._doJudgmentForSimilarCells = function(judgment, params) { DataTableCellUI.prototype._doJudgmentForSimilarCells = function(judgment, params) {
params = params || {}; params = params || {};
params.row = this._rowIndex; params.columnName = cellIndexToColumn(this._cellIndex).headerLabel;
params.cell = this._cellIndex; params.similarValue = this._cell.v;
params.judgment = judgment; params.judgment = judgment;
ui.dataTableView.doPostThenUpdate("recon-judge-similar-cells", params); ui.dataTableView.doPostThenUpdate("recon-judge-similar-cells", params);
@ -182,16 +194,21 @@ DataTableCellUI.prototype._searchForMatch = function() {
$('<button></button>').text("Match").click(function() { $('<button></button>').text("Match").click(function() {
if (match != null) { if (match != null) {
var params = { var params = {
row: self._rowIndex, judgment: "matched",
cell: self._cellIndex,
topicID: match.id, topicID: match.id,
topicGUID: match.guid, topicGUID: match.guid,
topicName: match.name, topicName: match.name,
types: $.map(match.type, function(elmt) { return elmt.id; }).join(",") types: $.map(match.type, function(elmt) { return elmt.id; }).join(",")
}; };
if (checkSimilar[0].checked) { if (checkSimilar[0].checked) {
params.similarValue = self._cell.v;
params.columnName = cellIndexToColumn(self._cellIndex).headerLabel;
ui.dataTableView.doPostThenUpdate("recon-judge-similar-cells", params); ui.dataTableView.doPostThenUpdate("recon-judge-similar-cells", params);
} else { } else {
params.row = self._rowIndex;
params.cell = self._cellIndex;
self.doPostThenUpdate("recon-judge-one-cell", params); self.doPostThenUpdate("recon-judge-one-cell", params);
} }

View File

@ -54,7 +54,7 @@ ReconDialog.prototype._createDialog = function() {
var optionDiv = $('<p>').appendTo(body); var optionDiv = $('<p>').appendTo(body);
var autoMatchCheckbox = $('<input type="checkbox" checked />').appendTo(optionDiv); var autoMatchCheckbox = $('<input type="checkbox" checked />').appendTo(optionDiv);
$('<span>').text(" Auto-match correctly-typed candidates scoring at least ").appendTo(optionDiv); $('<span>').text(" Auto-match correctly-typed candidates scoring at least ").appendTo(optionDiv);
var minScoreInput = $('<input/>').attr("value", "100").appendTo(optionDiv); var minScoreInput = $('<input/>').width("3em").attr("value", "100").appendTo(optionDiv);
$('<button></button>').text("Start Reconciling").click(function() { $('<button></button>').text("Start Reconciling").click(function() {
var choices = $('input[name="recon-dialog-type-choice"]:checked'); var choices = $('input[name="recon-dialog-type-choice"]:checked');