From e4b01cb36c1c09127ed248c997ede9b6d366ec50 Mon Sep 17 00:00:00 2001 From: David Huynh Date: Mon, 22 Feb 2010 20:25:45 +0000 Subject: [PATCH] Make similar cell judgments an abstract operation. git-svn-id: http://google-refine.googlecode.com/svn/trunk@120 7d457c2a-affb-35e4-300a-418c747d4874 --- .../recon/ReconJudgeOneCellCommand.java | 107 +++----- .../recon/ReconJudgeSimilarCellsCommand.java | 236 +++--------------- .../com/metaweb/gridworks/model/Recon.java | 29 ++- .../gridworks/model/ReconCandidate.java | 5 +- .../operations/OperationRegistry.java | 1 + .../ReconJudgeSimilarCellsOperation.java | 185 ++++++++++++++ src/main/webapp/scripts/project.js | 11 + .../webapp/scripts/project/browsing-engine.js | 9 +- .../scripts/project/data-table-cell-ui.js | 39 ++- .../webapp/scripts/project/recon-dialog.js | 2 +- 10 files changed, 322 insertions(+), 302 deletions(-) create mode 100644 src/main/java/com/metaweb/gridworks/operations/ReconJudgeSimilarCellsOperation.java diff --git a/src/main/java/com/metaweb/gridworks/commands/recon/ReconJudgeOneCellCommand.java b/src/main/java/com/metaweb/gridworks/commands/recon/ReconJudgeOneCellCommand.java index 25d67990c..88c823989 100644 --- a/src/main/java/com/metaweb/gridworks/commands/recon/ReconJudgeOneCellCommand.java +++ b/src/main/java/com/metaweb/gridworks/commands/recon/ReconJudgeOneCellCommand.java @@ -18,6 +18,7 @@ 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.Recon.Judgment; import com.metaweb.gridworks.model.changes.CellChange; import com.metaweb.gridworks.process.QuickHistoryEntryProcess; @@ -31,36 +32,30 @@ public class ReconJudgeOneCellCommand extends Command { int rowIndex = Integer.parseInt(request.getParameter("row")); int cellIndex = Integer.parseInt(request.getParameter("cell")); - String judgment = request.getParameter("judgment"); - - JudgeOneCellProcess process = null; + Judgment judgment = Recon.stringToJudgment(request.getParameter("judgment")); - if (judgment != null) { - process = new JudgeOneCellProcess( - project, - "Judge one cell's recon result", - judgment, - rowIndex, - cellIndex, - request.getParameter("candidate") - ); - } else { - ReconCandidate match = new ReconCandidate( - request.getParameter("topicID"), + ReconCandidate match = null; + String topicID = request.getParameter("topicID"); + if (topicID != null) { + String scoreString = request.getParameter("score"); + + match = new ReconCandidate( + topicID, request.getParameter("topicGUID"), request.getParameter("topicName"), request.getParameter("types").split(","), - 100 - ); - - process = new JudgeOneCellProcess( - project, - "Judge one cell's recon result", - rowIndex, - cellIndex, - match + scoreString != null ? Double.parseDouble(scoreString) : 100 ); } + + JudgeOneCellProcess process = new JudgeOneCellProcess( + project, + "Judge one cell's recon result", + judgment, + rowIndex, + cellIndex, + match + ); boolean done = project.processManager.queueProcess(process); if (done) { @@ -80,27 +75,24 @@ public class ReconJudgeOneCellCommand extends Command { protected class JudgeOneCellProcess extends QuickHistoryEntryProcess { final int rowIndex; final int cellIndex; - final String judgment; - final String candidateID; + final Judgment judgment; final ReconCandidate match; 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); - 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) { - super(project, briefDescription); this.rowIndex = rowIndex; this.cellIndex = cellIndex; - this.judgment = null; - this.candidateID = null; this.match = match; } @@ -126,45 +118,20 @@ public class ReconJudgeOneCellCommand extends Command { ", containing \"" + cell.value + "\""; String description = null; - - if (match != null) { + if (judgment == Judgment.None) { + 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.match = this.match; description = "Match " + this.match.topicName + " (" + match.topicID + ") to " + 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); diff --git a/src/main/java/com/metaweb/gridworks/commands/recon/ReconJudgeSimilarCellsCommand.java b/src/main/java/com/metaweb/gridworks/commands/recon/ReconJudgeSimilarCellsCommand.java index ac949ed9d..05a23b302 100644 --- a/src/main/java/com/metaweb/gridworks/commands/recon/ReconJudgeSimilarCellsCommand.java +++ b/src/main/java/com/metaweb/gridworks/commands/recon/ReconJudgeSimilarCellsCommand.java @@ -1,220 +1,44 @@ 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.HttpServletResponse; -import org.json.JSONWriter; +import org.json.JSONObject; -import com.metaweb.gridworks.browsing.Engine; -import com.metaweb.gridworks.browsing.FilteredRows; -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.commands.EngineDependentCommand; +import com.metaweb.gridworks.model.AbstractOperation; import com.metaweb.gridworks.model.ReconCandidate; -import com.metaweb.gridworks.model.Row; -import com.metaweb.gridworks.model.changes.CellChange; -import com.metaweb.gridworks.model.changes.MassCellChange; -import com.metaweb.gridworks.process.QuickHistoryEntryProcess; +import com.metaweb.gridworks.operations.ReconJudgeSimilarCellsOperation; + +public class ReconJudgeSimilarCellsCommand extends EngineDependentCommand { -public class ReconJudgeSimilarCellsCommand extends Command { @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + protected AbstractOperation createOperation( + HttpServletRequest request, JSONObject engineConfig) throws Exception { - try { - Project project = getProject(request); - Engine engine = getEngine(request, project); - - int rowIndex = Integer.parseInt(request.getParameter("row")); - int cellIndex = Integer.parseInt(request.getParameter("cell")); - String judgment = request.getParameter("judgment"); - - JudgeSimilarCellsProcess process = null; - - if (judgment != null) { - process = new JudgeSimilarCellsProcess( - project, - engine, - "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; + String columnName = request.getParameter("columnName"); + String similarValue = request.getParameter("similarValue"); + String judgment = request.getParameter("judgment"); - 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; + ReconCandidate match = null; + String topicID = request.getParameter("topicID"); + if (topicID != null) { + String scoreString = request.getParameter("score"); + + match = new ReconCandidate( + topicID, + request.getParameter("topicGUID"), + request.getParameter("topicName"), + request.getParameter("types").split(","), + scoreString != null ? Double.parseDouble(scoreString) : 100 + ); } - JudgeSimilarCellsProcess(Project project, Engine engine, String briefDescription, int rowIndex, int cellIndex, ReconCandidate match) { - super(project, briefDescription); - this.engine = engine; - this.rowIndex = rowIndex; - this.cellIndex = cellIndex; - this.judgment = null; - 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 cellChanges = new ArrayList(_project.rows.size()); - String similarValue = cell.value.toString(); - - RowVisitor rowVisitor = new RowVisitor() { - List cellChanges; - String similarValue; - - public RowVisitor init(List 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); - } + return new ReconJudgeSimilarCellsOperation( + engineConfig, + columnName, + similarValue, + judgment, + match + ); } } diff --git a/src/main/java/com/metaweb/gridworks/model/Recon.java b/src/main/java/com/metaweb/gridworks/model/Recon.java index c79d6608e..4bc75618e 100644 --- a/src/main/java/com/metaweb/gridworks/model/Recon.java +++ b/src/main/java/com/metaweb/gridworks/model/Recon.java @@ -22,6 +22,27 @@ public class Recon implements Serializable, HasFields, Jsonizable { 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_nameMatch = 1; static public int Feature_nameLevenshtein = 2; @@ -94,13 +115,7 @@ public class Recon implements Serializable, HasFields, Jsonizable { } protected String judgmentToString() { - if (judgment == Judgment.Matched) { - return "matched"; - } else if (judgment == Judgment.New) { - return "new"; - } else { - return "none"; - } + return judgmentToString(judgment); } public class Features implements HasFields { diff --git a/src/main/java/com/metaweb/gridworks/model/ReconCandidate.java b/src/main/java/com/metaweb/gridworks/model/ReconCandidate.java index af0d39bc0..c73f449dc 100644 --- a/src/main/java/com/metaweb/gridworks/model/ReconCandidate.java +++ b/src/main/java/com/metaweb/gridworks/model/ReconCandidate.java @@ -46,17 +46,14 @@ public class ReconCandidate implements Serializable, HasFields, Jsonizable { writer.object(); 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("score"); writer.value(score); - - /* writer.key("types"); writer.array(); for (String typeID : typeIDs) { writer.value(typeID); } writer.endArray(); - */ writer.endObject(); } diff --git a/src/main/java/com/metaweb/gridworks/operations/OperationRegistry.java b/src/main/java/com/metaweb/gridworks/operations/OperationRegistry.java index 794e1346a..4f9450cc5 100644 --- a/src/main/java/com/metaweb/gridworks/operations/OperationRegistry.java +++ b/src/main/java/com/metaweb/gridworks/operations/OperationRegistry.java @@ -23,6 +23,7 @@ public abstract class OperationRegistry { register("recon-match-best-candidates", ReconMatchBestCandidatesOperation.class); register("recon-discard-judgments", ReconDiscardJudgmentsOperation.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-split", MultiValuedCellSplitOperation.class); diff --git a/src/main/java/com/metaweb/gridworks/operations/ReconJudgeSimilarCellsOperation.java b/src/main/java/com/metaweb/gridworks/operations/ReconJudgeSimilarCellsOperation.java new file mode 100644 index 000000000..db0779081 --- /dev/null +++ b/src/main/java/com/metaweb/gridworks/operations/ReconJudgeSimilarCellsOperation.java @@ -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 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 cellChanges) throws Exception { + Column column = project.columnModel.getColumnByName(_columnName); + + return new RowVisitor() { + int _cellIndex; + List _cellChanges; + + public RowVisitor init(int cellIndex, List 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); + } +} diff --git a/src/main/webapp/scripts/project.js b/src/main/webapp/scripts/project.js index fb8821c56..0af9c0950 100644 --- a/src/main/webapp/scripts/project.js +++ b/src/main/webapp/scripts/project.js @@ -62,3 +62,14 @@ function reinitializeProjectData(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; +} \ No newline at end of file diff --git a/src/main/webapp/scripts/project/browsing-engine.js b/src/main/webapp/scripts/project/browsing-engine.js index f3f82c5cb..d6cdf8ade 100644 --- a/src/main/webapp/scripts/project/browsing-engine.js +++ b/src/main/webapp/scripts/project/browsing-engine.js @@ -10,10 +10,13 @@ BrowsingEngine.prototype._initializeUI = function() { var container = this._div.empty(); }; -BrowsingEngine.prototype.getJSON = function() { +BrowsingEngine.prototype.getJSON = function(keepUnrestrictedFacets) { var a = { facets: [] }; 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; }; @@ -57,7 +60,7 @@ BrowsingEngine.prototype.update = function() { $.post( "/command/compute-facets?" + $.param({ project: theProject.id }), - { engine: JSON.stringify(ui.browsingEngine.getJSON()) }, + { engine: JSON.stringify(ui.browsingEngine.getJSON(true)) }, function(data) { var facetData = data.facets; diff --git a/src/main/webapp/scripts/project/data-table-cell-ui.js b/src/main/webapp/scripts/project/data-table-cell-ui.js index 832edeae9..9978725d6 100644 --- a/src/main/webapp/scripts/project/data-table-cell-ui.js +++ b/src/main/webapp/scripts/project/data-table-cell-ui.js @@ -62,14 +62,14 @@ DataTableCellUI.prototype._render = function() { .addClass("data-table-recon-match-similar") .attr("title", "Match this topic to this cell and other cells with the same content") .appendTo(li).click(function(evt) { - self._doMatchTopicToSimilarCells(candidate.id); + self._doMatchTopicToSimilarCells(candidate); }); $(' ') .addClass("data-table-recon-match") .attr("title", "Match this topic to this cell") .appendTo(li).click(function(evt) { - self._doMatchTopicToOneCell(candidate.id); + self._doMatchTopicToOneCell(candidate); }); $('') @@ -122,7 +122,7 @@ DataTableCellUI.prototype._render = function() { }; DataTableCellUI.prototype._doRematch = function() { - this._doJudgment("discard"); + this._doJudgment("none"); }; DataTableCellUI.prototype._doMatchNewTopicToOneCell = function() { @@ -133,12 +133,24 @@ DataTableCellUI.prototype._doMatchNewTopicToSimilarCells = function() { this._doJudgmentForSimilarCells("new"); }; -DataTableCellUI.prototype._doMatchTopicToOneCell = function(candidateID) { - this._doJudgment("match", { candidate : candidateID }); +DataTableCellUI.prototype._doMatchTopicToOneCell = function(candidate) { + this._doJudgment("matched", { + topicID : candidate.id, + topicGUID: candidate.guid, + topicName: candidate.name, + score: candidate.score, + types: candidate.types.join(",") + }); }; -DataTableCellUI.prototype._doMatchTopicToSimilarCells = function(candidateID) { - this._doJudgmentForSimilarCells("match", { candidate : candidateID }); +DataTableCellUI.prototype._doMatchTopicToSimilarCells = function(candidate) { + 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) { @@ -151,8 +163,8 @@ DataTableCellUI.prototype._doJudgment = function(judgment, params) { DataTableCellUI.prototype._doJudgmentForSimilarCells = function(judgment, params) { params = params || {}; - params.row = this._rowIndex; - params.cell = this._cellIndex; + params.columnName = cellIndexToColumn(this._cellIndex).headerLabel; + params.similarValue = this._cell.v; params.judgment = judgment; ui.dataTableView.doPostThenUpdate("recon-judge-similar-cells", params); @@ -182,16 +194,21 @@ DataTableCellUI.prototype._searchForMatch = function() { $('').text("Match").click(function() { if (match != null) { var params = { - row: self._rowIndex, - cell: self._cellIndex, + judgment: "matched", topicID: match.id, topicGUID: match.guid, topicName: match.name, types: $.map(match.type, function(elmt) { return elmt.id; }).join(",") }; if (checkSimilar[0].checked) { + params.similarValue = self._cell.v; + params.columnName = cellIndexToColumn(self._cellIndex).headerLabel; + ui.dataTableView.doPostThenUpdate("recon-judge-similar-cells", params); } else { + params.row = self._rowIndex; + params.cell = self._cellIndex; + self.doPostThenUpdate("recon-judge-one-cell", params); } diff --git a/src/main/webapp/scripts/project/recon-dialog.js b/src/main/webapp/scripts/project/recon-dialog.js index fb2e32533..aa2e3fdb6 100644 --- a/src/main/webapp/scripts/project/recon-dialog.js +++ b/src/main/webapp/scripts/project/recon-dialog.js @@ -54,7 +54,7 @@ ReconDialog.prototype._createDialog = function() { var optionDiv = $('

').appendTo(body); var autoMatchCheckbox = $('').appendTo(optionDiv); $('').text(" Auto-match correctly-typed candidates scoring at least ").appendTo(optionDiv); - var minScoreInput = $('').attr("value", "100").appendTo(optionDiv); + var minScoreInput = $('').width("3em").attr("value", "100").appendTo(optionDiv); $('').text("Start Reconciling").click(function() { var choices = $('input[name="recon-dialog-type-choice"]:checked');