2010-10-20 20:11:15 +02:00
|
|
|
/*
|
|
|
|
|
|
|
|
Copyright 2010, Google Inc.
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions are
|
|
|
|
met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
* Redistributions in binary form must reproduce the above
|
|
|
|
copyright notice, this list of conditions and the following disclaimer
|
|
|
|
in the documentation and/or other materials provided with the
|
|
|
|
distribution.
|
|
|
|
* Neither the name of Google Inc. nor the names of its
|
|
|
|
contributors may be used to endorse or promote products derived from
|
|
|
|
this software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2010-08-09 03:13:57 +02:00
|
|
|
DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
|
|
|
|
var doReconcile = function() {
|
|
|
|
new ReconDialog(column);
|
|
|
|
};
|
|
|
|
|
|
|
|
var doReconDiscardJudgments = function() {
|
2010-09-23 00:55:28 +02:00
|
|
|
Refine.postCoreProcess(
|
2010-08-09 03:13:57 +02:00
|
|
|
"recon-discard-judgments",
|
2010-10-22 09:25:27 +02:00
|
|
|
{ columnName: column.name, clearData: false },
|
2010-08-09 03:13:57 +02:00
|
|
|
null,
|
|
|
|
{ cellsChanged: true, columnStatsChanged: true }
|
|
|
|
);
|
|
|
|
};
|
2010-10-22 09:25:27 +02:00
|
|
|
|
|
|
|
var doClearReconData = function() {
|
|
|
|
Refine.postCoreProcess(
|
|
|
|
"recon-discard-judgments",
|
|
|
|
{ columnName: column.name, clearData: true },
|
|
|
|
null,
|
|
|
|
{ cellsChanged: true, columnStatsChanged: true }
|
|
|
|
);
|
|
|
|
}
|
2010-08-09 03:13:57 +02:00
|
|
|
|
|
|
|
var doReconMatchBestCandidates = function() {
|
2010-09-23 00:55:28 +02:00
|
|
|
Refine.postCoreProcess(
|
2010-08-09 03:13:57 +02:00
|
|
|
"recon-match-best-candidates",
|
|
|
|
{ columnName: column.name },
|
|
|
|
null,
|
|
|
|
{ cellsChanged: true, columnStatsChanged: true }
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
var doReconMarkNewTopics = function(shareNewTopics) {
|
2010-09-23 00:55:28 +02:00
|
|
|
Refine.postCoreProcess(
|
2010-08-09 03:13:57 +02:00
|
|
|
"recon-mark-new-topics",
|
|
|
|
{ columnName: column.name, shareNewTopics: shareNewTopics },
|
|
|
|
null,
|
|
|
|
{ cellsChanged: true, columnStatsChanged: true }
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
var doSearchToMatch = function() {
|
|
|
|
var frame = DialogSystem.createDialog();
|
|
|
|
frame.width("400px");
|
|
|
|
|
|
|
|
var header = $('<div></div>').addClass("dialog-header").text("Search for Match").appendTo(frame);
|
|
|
|
var body = $('<div></div>').addClass("dialog-body").appendTo(frame);
|
|
|
|
var footer = $('<div></div>').addClass("dialog-footer").appendTo(frame);
|
|
|
|
|
|
|
|
$('<p></p>').text("Search Freebase for a topic to match all filtered cells:").appendTo(body);
|
|
|
|
|
|
|
|
var input = $('<input />').appendTo($('<p></p>').appendTo(body));
|
|
|
|
|
|
|
|
input.suggest({}).bind("fb-select", function(e, data) {
|
|
|
|
var query = {
|
|
|
|
"id" : data.id,
|
|
|
|
"type" : []
|
|
|
|
};
|
|
|
|
var baseUrl = "http://api.freebase.com/api/service/mqlread";
|
|
|
|
var url = baseUrl + "?" + $.param({ query: JSON.stringify({ query: query }) }) + "&callback=?";
|
|
|
|
|
|
|
|
$.getJSON(
|
|
|
|
url,
|
|
|
|
null,
|
|
|
|
function(o) {
|
|
|
|
var types = "result" in o ? o.result.type : [];
|
|
|
|
|
2010-09-23 00:55:28 +02:00
|
|
|
Refine.postCoreProcess(
|
2010-08-09 03:13:57 +02:00
|
|
|
"recon-match-specific-topic-to-cells",
|
|
|
|
{
|
|
|
|
columnName: column.name,
|
|
|
|
topicID: data.id,
|
|
|
|
topicGUID: data.guid,
|
|
|
|
topicName: data.name,
|
|
|
|
types: types.join(",")
|
|
|
|
},
|
|
|
|
null,
|
|
|
|
{ cellsChanged: true, columnStatsChanged: true }
|
|
|
|
);
|
|
|
|
|
|
|
|
DialogSystem.dismissUntil(level - 1);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2010-10-16 08:43:01 +02:00
|
|
|
$('<button class="button"></button>').text("Cancel").click(function() {
|
2010-08-09 03:13:57 +02:00
|
|
|
DialogSystem.dismissUntil(level - 1);
|
|
|
|
}).appendTo(footer);
|
|
|
|
|
|
|
|
var level = DialogSystem.showDialog(frame);
|
|
|
|
input.focus().data("suggest").textchange();
|
|
|
|
};
|
|
|
|
|
2010-10-22 09:25:27 +02:00
|
|
|
var doCopyAcrossColumns = function() {
|
|
|
|
var frame = $(DOM.loadHTML("core", "scripts/views/data-table/copy-recon-across-columns-dialog.html"));
|
|
|
|
var elmts = DOM.bind(frame);
|
|
|
|
elmts.dialogHeader.text("Copy recon judgments from column " + column.name);
|
|
|
|
|
|
|
|
var columns = theProject.columnModel.columns;
|
|
|
|
for (var i = 0; i < columns.length; i++) {
|
|
|
|
var column2 = columns[i];
|
|
|
|
if (column !== column2) {
|
|
|
|
$('<option>').attr("value", column2.name).text(column2.name).appendTo(elmts.toColumnSelect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var level = DialogSystem.showDialog(frame);
|
|
|
|
var dismiss = function() { DialogSystem.dismissUntil(level - 1); };
|
|
|
|
|
|
|
|
elmts.cancelButton.click(dismiss);
|
|
|
|
elmts.okButton.click(function() {
|
|
|
|
var config = {
|
|
|
|
fromColumnName: column.name,
|
|
|
|
toColumnName: [],
|
|
|
|
judgment: [],
|
|
|
|
applyToJudgedCells: elmts.applyToJudgedCellsCheckbox[0].checked
|
|
|
|
};
|
|
|
|
|
|
|
|
if (elmts.newCheckbox[0].checked) {
|
|
|
|
config.judgment.push("new");
|
|
|
|
}
|
|
|
|
if (elmts.matchCheckbox[0].checked) {
|
|
|
|
config.judgment.push("matched");
|
|
|
|
}
|
|
|
|
elmts.toColumnSelect.find("option").each(function() {
|
|
|
|
if (this.selected) {
|
|
|
|
config.toColumnName.push(this.value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (config.toColumnName.length == 0) {
|
|
|
|
alert("Please select some other column to copy to.");
|
|
|
|
} else if (config.judgment.length == 0) {
|
|
|
|
alert("Please select at least one kind of judgment to copy.");
|
|
|
|
} else {
|
|
|
|
Refine.postCoreProcess(
|
|
|
|
"recon-copy-across-columns",
|
|
|
|
null,
|
|
|
|
config,
|
|
|
|
{ rowsChanged: true }
|
|
|
|
);
|
|
|
|
dismiss();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2010-08-09 03:13:57 +02:00
|
|
|
MenuSystem.appendTo(menu, [ "core/reconcile" ], [
|
|
|
|
{
|
2010-10-08 03:54:00 +02:00
|
|
|
id: "core/reconcile",
|
2010-08-09 03:13:57 +02:00
|
|
|
label: "Start Reconciling ...",
|
|
|
|
tooltip: "Reconcile text in this column with topics on Freebase",
|
|
|
|
click: doReconcile
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
2010-10-08 03:54:00 +02:00
|
|
|
id: "core/facets",
|
2010-08-09 03:13:57 +02:00
|
|
|
label: "Facets",
|
|
|
|
submenu: [
|
|
|
|
{
|
2010-10-08 03:54:00 +02:00
|
|
|
id: "core/by-judgment",
|
2010-08-09 03:13:57 +02:00
|
|
|
label: "By Judgment",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name" : column.name,
|
|
|
|
"columnName" : column.name,
|
|
|
|
"expression" : "cell.recon.judgment",
|
|
|
|
"omitError" : true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"scroll" : false
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
2010-10-08 03:54:00 +02:00
|
|
|
id: "core/by-best-candidates-score",
|
|
|
|
label: "Best Candidate's Score",
|
2010-08-09 03:13:57 +02:00
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
|
|
|
{
|
|
|
|
"name" : column.name,
|
|
|
|
"columnName" : column.name,
|
|
|
|
"expression" : "cell.recon.best.score",
|
|
|
|
"mode" : "range"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2010-10-08 03:54:00 +02:00
|
|
|
id: "core/by-best-candidates-type-match",
|
2010-08-09 03:13:57 +02:00
|
|
|
label: "Best Candidate's Type Match",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name" : column.name,
|
|
|
|
"columnName" : column.name,
|
|
|
|
"expression" : "cell.recon.features.typeMatch",
|
|
|
|
"omitError" : true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"scroll" : false
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2010-10-08 03:54:00 +02:00
|
|
|
id: "core/by-best-candidates-name-match",
|
2010-08-09 03:13:57 +02:00
|
|
|
label: "Best Candidate's Name Match",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name" : column.name,
|
|
|
|
"columnName" : column.name,
|
|
|
|
"expression" : "cell.recon.features.nameMatch",
|
|
|
|
"omitError" : true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"scroll" : false
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
2010-10-08 03:54:00 +02:00
|
|
|
id: "core/by-best-candidates-name-edit-distance",
|
2010-08-09 03:13:57 +02:00
|
|
|
label: "Best Candidate's Name Edit Distance",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
|
|
|
{
|
|
|
|
"name" : column.name,
|
|
|
|
"columnName" : column.name,
|
|
|
|
"expression" : "cell.recon.features.nameLevenshtein",
|
|
|
|
"mode" : "range"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2010-10-08 03:54:00 +02:00
|
|
|
id: "core/by-best-candidates-name-word-similarity",
|
2010-08-09 03:13:57 +02:00
|
|
|
label: "Best Candidate's Name Word Similarity",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
|
|
|
{
|
|
|
|
"name" : column.name,
|
|
|
|
"columnName" : column.name,
|
|
|
|
"expression" : "cell.recon.features.nameWordDistance",
|
|
|
|
"mode" : "range"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
2010-10-08 03:54:00 +02:00
|
|
|
id: "core/by-best-candidates-types",
|
2010-08-09 03:13:57 +02:00
|
|
|
label: "Best Candidate's Types",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name" : column.name,
|
|
|
|
"columnName" : column.name,
|
|
|
|
"expression" : "cell.recon.best.type",
|
|
|
|
"omitError" : true
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2010-08-13 18:26:33 +02:00
|
|
|
{
|
2010-10-08 03:54:00 +02:00
|
|
|
id: "core/qa-facets",
|
2010-08-13 18:26:33 +02:00
|
|
|
label: "QA Facets",
|
|
|
|
submenu: [
|
|
|
|
{
|
2010-10-08 03:54:00 +02:00
|
|
|
id: "core/by-qa-results",
|
2010-08-13 18:26:33 +02:00
|
|
|
label: "QA Results",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name" : column.name + " QA Results",
|
|
|
|
"columnName" : column.name,
|
|
|
|
"expression" : "cell.recon.features.qaResult"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2010-10-08 03:54:00 +02:00
|
|
|
id: "core/by-judgment-actions",
|
2010-08-13 18:26:33 +02:00
|
|
|
label: "Judgment Actions",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name" : column.name + " Judgment Actions",
|
|
|
|
"columnName" : column.name,
|
|
|
|
"expression" : "cell.recon.judgmentAction"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2010-10-08 03:54:00 +02:00
|
|
|
id: "core/by-judgment-history-entries",
|
2010-08-13 18:26:33 +02:00
|
|
|
label: "Judgment History Entries",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name" : column.name + " History Entries",
|
|
|
|
"columnName" : column.name,
|
|
|
|
"expression" : "cell.recon.judgmentHistoryEntry"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2010-08-09 03:13:57 +02:00
|
|
|
{
|
2010-10-08 03:54:00 +02:00
|
|
|
id: "core/actions",
|
2010-08-09 03:13:57 +02:00
|
|
|
label: "Actions",
|
|
|
|
submenu: [
|
|
|
|
{
|
2010-10-08 03:54:00 +02:00
|
|
|
id: "core/match-to-best-candidate",
|
2010-08-09 03:13:57 +02:00
|
|
|
label: "Match Each Cell to Its Best Candidate",
|
|
|
|
tooltip: "Match each cell to its best candidate in this column for all current filtered rows",
|
|
|
|
click: doReconMatchBestCandidates
|
|
|
|
},
|
|
|
|
{
|
2010-10-08 03:54:00 +02:00
|
|
|
id: "core/match-to-new-topic",
|
2010-08-09 03:13:57 +02:00
|
|
|
label: "Create a New Topic for Each Cell",
|
|
|
|
tooltip: "Mark to create one new topic for each cell in this column for all current filtered rows",
|
|
|
|
click: function() {
|
|
|
|
doReconMarkNewTopics(false);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
2010-10-08 03:54:00 +02:00
|
|
|
id: "core/match-similar-to-new-topic",
|
2010-08-09 03:13:57 +02:00
|
|
|
label: "Create One New Topic for Similar Cells",
|
|
|
|
tooltip: "Mark to create one new topic for each group of similar cells in this column for all current filtered rows",
|
|
|
|
click: function() {
|
|
|
|
doReconMarkNewTopics(true);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2010-10-08 03:54:00 +02:00
|
|
|
id: "core/match-to-specific",
|
2010-08-09 03:13:57 +02:00
|
|
|
label: "Match All Filtered Cells to ...",
|
|
|
|
tooltip: "Search for a topic to match all filtered cells to",
|
|
|
|
click: doSearchToMatch
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
2010-10-08 03:54:00 +02:00
|
|
|
id: "core/discard-judgments",
|
2010-08-09 03:13:57 +02:00
|
|
|
label: "Discard Reconciliation Judgments",
|
|
|
|
tooltip: "Discard reconciliaton judgments in this column for all current filtered rows",
|
|
|
|
click: doReconDiscardJudgments
|
2010-10-22 09:25:27 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "core/clear-recon-data",
|
|
|
|
label: "Clear Recon Data",
|
|
|
|
tooltip: "Clear recon data in this column for all current filtered rows",
|
|
|
|
click: doClearReconData
|
2010-08-09 03:13:57 +02:00
|
|
|
}
|
|
|
|
]
|
2010-10-22 09:25:27 +02:00
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
id: "core/copy-across-columns",
|
|
|
|
label: "Copy Recon Data ...",
|
|
|
|
tooltip: "Copy this column's recon data to other columns",
|
|
|
|
click: doCopyAcrossColumns
|
2010-08-09 03:13:57 +02:00
|
|
|
}
|
|
|
|
]);
|
|
|
|
});
|