Wednesday, March 7, 2012

Integrating Open Reconcile with Google Refine

Since I published a WAR of open reconcile, I figure I should add a note on what to do if you want to have better integration between Google Refine and Open Reconcile (and have Google Refine's source code).

There are just two files you need to modify to add a "Configure Open Reconcile" option to the "Start reconciling" dialog box. First off, do know that I am sacrificing some FreeBase integration functionality. If this bothers you, don't follow these instructions. Also, if editing javascript/html scares you (why are you at this blog?), don't do this.

We're going to turn the "Add namespace" button into the button we want. It's rather simple, just open recon-dialog.html from grefine/main/webapp/modules/core/scripts/reconciliation/ Just change the text of the button from "Add namespace" to "Configure Open Reconcile".

Next, you'll undoubtedly see it calls a function. The function can be found in the same folder in recon-dialog.js. Find the function _addNamespacedService. Comment out or delete all of the existing code in that function (keeping in mind that it's not well-tabbed) and put this in instead:

     var self = this;
      var dialog = $(DOM.loadHTML("core", "scripts/reconciliation/config-open-service-dialog.html"));
      var elmts = DOM.bind(dialog);

      var level = DialogSystem.showDialog(dialog);
      var dismiss = function() {
        DialogSystem.dismissUntil(level - 1);
      };

      elmts.cancelButton.click(dismiss);
      elmts.addButton.click(function() {
        var url = $.trim(elmts.input[0].value);
        if (url.length > 10) {
            window.open(url.substring(0,url.length-10));
        }
        dismiss();
      });
      elmts.input.focus().select();

If you're paying attention, you will see that I'm referencing an html file that doesn't exist. I just coped add-standard-service-dialog.html and changed    
 <button class="button" bind="addButton">Add Service</button>
to
<button class="button" bind="addButton">Go To Config</button>

Okay, just return the file or re-create distribution files if you don't run it in the console (see <a href="http://code.google.com/p/google-refine/wiki/DevelopersGuide">Google Refine documentation</a> for how to do that).

I find this is helpful so I don't have to keep links to everything. It takes the url in, chops of the "/reconcile" that points to the service, and in this webapp the configuration screen is at the root. To do most options (Delete a row, preview data the row will pull, and eventually and substitution rules or synonyms) you need to "List All Current Libraries".

No comments:

Post a Comment