Merge pull request #1581 from OpenRefine/issue1376

Migrate "Match all filtered cells" to use standard reconciliation services
This commit is contained in:
Antonin Delpeuch 2018-05-06 08:46:03 +02:00 committed by GitHub
commit 34941ce632
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 29 deletions

View File

@ -461,7 +461,7 @@
"valid-values": "Valid values", "valid-values": "Valid values",
"blanks": "Blanks", "blanks": "Blanks",
"errors": "Errors", "errors": "Errors",
"search-fb-topic": "Search Freebase for a topic to match all filtered cells:", "search-fb-topic": "Search for an item to match all filtered cells:",
"copy-recon-judg": "Copy recon judgments from column", "copy-recon-judg": "Copy recon judgments from column",
"copy-to-col": "Copy to Columns", "copy-to-col": "Copy to Columns",
"copy-opt": "Copying Options", "copy-opt": "Copying Options",

View File

@ -504,7 +504,7 @@
"re-trans": "Retransformer", "re-trans": "Retransformer",
"custom-text-facet": "Personnaliser la facette textuelle", "custom-text-facet": "Personnaliser la facette textuelle",
"match-other": "Apparier les autres cellules avec le même contenu", "match-other": "Apparier les autres cellules avec le même contenu",
"search-fb-topic": "Chercher dans Freebase un sujet qui correspond à toutes les cellules filtrées :", "search-fb-topic": "Chercher un item qui correspond à toutes les cellules filtrées :",
"from-col": "De la colonne", "from-col": "De la colonne",
"custom-numeric-label": "Facette numérique personnalisée sur la colonne", "custom-numeric-label": "Facette numérique personnalisée sur la colonne",
"start-recon": "Démarrer la réconciliation", "start-recon": "Démarrer la réconciliation",

View File

@ -73,6 +73,20 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
}; };
var doSearchToMatch = function() { var doSearchToMatch = function() {
var serviceUrl = null;
var service = null;
var suggestOptions = {};
if (column.reconConfig) {
serviceUrl = column.reconConfig.service;
}
if (serviceUrl) {
service = ReconciliationManager.getServiceFromUrl(serviceUrl);
}
if (service && service.suggest && service.suggest.entity) {
suggestOptions = $.extend({}, service.suggest.entity);
suggestOptions.query_param_name = "prefix";
}
var frame = DialogSystem.createDialog(); var frame = DialogSystem.createDialog();
frame.width("400px"); frame.width("400px");
@ -84,36 +98,24 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
var input = $('<input />').appendTo($('<p></p>').appendTo(body)); var input = $('<input />').appendTo($('<p></p>').appendTo(body));
input.suggest({}).bind("fb-select", function(e, data) { input.suggest(suggestOptions).bind("fb-select", function(e, data) {
var query = { var types = data.notable ? data.notable : [];
"id" : data.id,
"type" : []
};
var baseUrl = "https://www.googleapis.com/freebase/v1/mqlread?key=" + Freebase.API_KEY + "&";
var url = baseUrl + $.param({ query: JSON.stringify(query) }) + "&callback=?";
$.getJSON( Refine.postCoreProcess(
url, "recon-match-specific-topic-to-cells",
{
columnName: column.name,
topicID: data.id,
topicName: data.name,
types: types.join(","),
identifierSpace: service.identifierSpace,
schemaSpace: service.schemaSpace
},
null, null,
function(o) { { cellsChanged: true, columnStatsChanged: true }
var types = "result" in o ? o.result.type : []; );
Refine.postCoreProcess( DialogSystem.dismissUntil(level - 1);
"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);
}
);
}); });
$('<button class="button"></button>').text($.i18n._('core-buttons')["cancel"]).click(function() { $('<button class="button"></button>').text($.i18n._('core-buttons')["cancel"]).click(function() {