OpenEnergyPlatform / oeplatform

Repository for the code of the Open Energy Platform (OEP) website. The OEP provides an interface to the Open Energy Family
http://openenergyplatform.org/
GNU Affero General Public License v3.0
61 stars 19 forks source link

Automated ontological annotation in metadata #1017

Open jh-RLI opened 1 year ago

jh-RLI commented 1 year ago

A new feature that extends the MetaEdit. It should be possible to enter the OEO values into the metadata fields is_about and value_refenece in a user-friendly way. Often the same information has to be re-entered in different tables or columns. So it should be possible to search the OEO terms in the metaeditor and then enter the result into a field. In addition, recurring terms should be entered automatically in all fields.

This includes functions such as:

  1. read unique column-values in csv-file (that are strings) and paste into the metadata json
  2. drop-down menu in MetaEditor to search and make annotation suggestions in MetaEditor
  3. automatic insertion in json in field isAbout and valueReference
  4. update project-related database with ontological "project-dialect". The database will be updated with already annotated terms and will be used to automatically annotate (already known) project-specific terms in other tables
  5. OEO concept information should be shown in an information panel to allow users to make an informed annotation choice
jh-RLI commented 1 year ago

The dbpedia has already published a tool that is able to query the OEO and provide results. It is based on Java and fully containerized with Docker: see the architecture for more details.

adelmemariani commented 1 year ago

So it should be possible to search the OEO terms in the metaeditor and then enter the result into a field.

In OEP, we use the json-editor to generate a form for the metaeditor. Indeed, the json-editor has built-in functionality for the ‘autocomplete’ inputs.

To have an ‘autocomplete’, we should change the config in the ’oep-website/dataedit/static/metaedit/schema.json’. The example below is about making an autocomplete textbox for the 'name' in the value_reference:

"name": {
    "description": "Full name of the value",  
    "type": "autocomplete",  
    "title": "Name",  
    "format": "autocomplete",  
    "options": {
      "autocomplete": {
          "search": "search_name",
          "getResultValue": "getResultValue_name",
          "renderResult": "renderResult_name",
          "autoSelect": true
      }
  }
}

and also we need to write some code in the ‘oep-website/dataedit/static/metaedit/metaedit.js/meta edit.json’. The code below is the callback function (inside the init() method) that I wrote for the autocomplete.

window.JSONEditor.defaults.callbacks = {
  "autocomplete": {
    // Setup API calls
    "search_name": function search(jseditor_editor, input) {
        return ([
                  { ... the JSON object is returned here ...}
                ]);
    },
    "renderResult_name": function(jseditor_editor, result, props) {
        return ['<li ' + props + '>',
            '<div class="eiao-object-snippet">' + result.name.substring(0,50) + ' <small>' + result.class.substring(0,10) + 
            '<small></div>',
            '</li>'].join('');
    },
    "getResultValue_name": function getResultValue(jseditor_editor, result) {
        return result.key;
    }
  }
  };

The ‘autocomplete’ functionality is provided by an external library. Therefore we have to import it manually. The best place to import is the ’templates/dataedit/meta_edit.html’. The library itself should be downloaded inside the 'oep-website/dataedit/static' since we decided not to use CDN links anymore.

I pushed the code into a new branch called meta_edit_autocomplete.

chrwm commented 1 year ago

For documentation purposes, a screenshot of the first implementation of 2. drop-down menu in MetaEditor.

grafik

adelmemariani commented 1 year ago

The dbpedia-lookup service is now working with our MetaEdit tool.

metaedit

adelmemariani commented 1 year ago

Autocomplete with autofill the 'path' below it:

let path = String(jseditor_editor.path).replace("name", "path");
let path_uri = config.editor.getEditor(path);
path_uri.setValue(String(result.resource));

Metaedit_autocomplement_with_path

jh-RLI commented 1 year ago

I have started to document the architecture of the tool and what is currently missing. Also included the environment and relations. I post the current status here:

jh-RLI commented 1 year ago

Architektur_quick