From 93aa02f8c82c54fdbaca00283f2c51657471e36d Mon Sep 17 00:00:00 2001 From: Viktor Markovec Date: Mon, 12 Apr 2021 18:33:45 +0300 Subject: [PATCH 1/2] feat(ui): Change default representation to plain-text representation --- server/handlers/api_logic.py | 2 +- server/keynodes.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/server/handlers/api_logic.py b/server/handlers/api_logic.py index 492d43de..db285fb2 100644 --- a/server/handlers/api_logic.py +++ b/server/handlers/api_logic.py @@ -715,7 +715,7 @@ def get_default_ext_lang(self): return results[0][2] # setup default language - _lang = self.keynodes[KeynodeSysIdentifiers.scs_code] + _lang = self.keynodes[KeynodeSysIdentifiers.plain_text] self.set_default_ext_lang(_lang) return _lang diff --git a/server/keynodes.py b/server/keynodes.py index ec61d901..0ebd4613 100644 --- a/server/keynodes.py +++ b/server/keynodes.py @@ -109,6 +109,7 @@ class KeynodeSysIdentifiers: scg_code = 'scg_code' scs_code = 'scs_code' scn_code = 'scn_code' + plain_text = 'plain_text' # formats format_scs = 'format_scs' @@ -119,4 +120,4 @@ class KeynodeSysIdentifiers: system_element = 'system_element' Myself = 'Myself' - \ No newline at end of file + From 473e16f4861b422ba19377b4694138f1d5d28912 Mon Sep 17 00:00:00 2001 From: wcobalt Date: Fri, 21 May 2021 12:52:15 +0300 Subject: [PATCH 2/2] Intelligence mode --- Gruntfile.js | 11 + client/js/Core/main.js | 2 - client/js/Ui/IntModeHandler.js | 19 + client/js/Ui/core.js | 1 + client/js/Ui/intmodepanel.js | 48 ++ client/js/Ui/searchpanel.js | 552 +++++++++++++++++++- client/static/components/css/common.css | 8 + client/static/components/js/sc-int-mode.js | 181 +++++++ client/templates/base.html | 33 +- client/templates/components.html | 1 + components/intmode/modules/IntModule_Ims.js | 181 +++++++ 11 files changed, 1009 insertions(+), 28 deletions(-) create mode 100644 client/js/Ui/IntModeHandler.js create mode 100644 client/js/Ui/intmodepanel.js create mode 100644 client/static/components/js/sc-int-mode.js create mode 100644 components/intmode/modules/IntModule_Ims.js diff --git a/Gruntfile.js b/Gruntfile.js index a2658a87..249307b1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -4,6 +4,7 @@ module.exports = function(grunt) { var htmlDirPath = 'components/html/'; var scgDirPath = 'components/scg/'; var scsDirPath = 'components/scs/'; + var intModeDirPath = 'components/intmode/'; var webCoreCompPath = 'client/js/'; var clientJsDirPath = 'client/static/components/js/'; var clientCssDirPath = 'client/static/components/css/'; @@ -46,9 +47,15 @@ module.exports = function(grunt) { webCoreCompPath + 'Ui/userpanel.js', webCoreCompPath + 'Ui/expertmodepanel.js', webCoreCompPath + 'Ui/ExpertModeHandler.js', + webCoreCompPath + 'Ui/intmodepanel.js', + webCoreCompPath + 'Ui/IntModeHandler.js', ], dest: clientJsDirPath + 'sc-web-core.js', }, + int_mode : { + src: [intModeDirPath + 'modules/*.js'], + dest: clientJsDirPath + 'sc-int-mode.js' + }, github: { src: [githubDirPath + 'src/*.js'], dest: githubDirPath + 'static/components/js/github/github.js' @@ -198,6 +205,10 @@ module.exports = function(grunt) { files: webCoreCompPath + '**', tasks: ['concat:webcore'], }, + int_mode: { + files: intModeDirPath + '**', + tasks: ['concat:int_mode'], + }, githubJs: { files: githubDirPath + 'src/**', tasks: ['concat:github', 'copy:githubJs'], diff --git a/client/js/Core/main.js b/client/js/Core/main.js index d0ae213a..ebdd590b 100644 --- a/client/js/Core/main.js +++ b/client/js/Core/main.js @@ -1,6 +1,5 @@ var scHelper = null; var scKeynodes = null; -const currectYear = new Date().getFullYear(); SCWeb.core.Main = { @@ -134,7 +133,6 @@ SCWeb.core.Main = { }); }); - $('.copyright').text(`Copyright © 2012 - ${currectYear} OSTIS`); }, /** diff --git a/client/js/Ui/IntModeHandler.js b/client/js/Ui/IntModeHandler.js new file mode 100644 index 00000000..b08679a6 --- /dev/null +++ b/client/js/Ui/IntModeHandler.js @@ -0,0 +1,19 @@ +var intModeCheckbox; +var intModeSwitchingButtons; + +var intButton; + +$(document).ready(function () { + SCWeb.core.IntModeEnabled = false; + intModeCheckbox = document.querySelector('#int_mode-switching-checkbox'); + + if (intModeCheckbox) { + intModeCheckbox.checked = SCWeb.core.IntModeEnabled; + if (!intModeCheckbox.checked) { + } + intModeCheckbox.onclick = function () { + SCWeb.core.IntModeEnabled = intModeCheckbox.checked; + SCWeb.core.EventManager.emit("int_mode_changed"); + }; + } +}); diff --git a/client/js/Ui/core.js b/client/js/Ui/core.js index 0b065bc9..96b5a10c 100644 --- a/client/js/Ui/core.js +++ b/client/js/Ui/core.js @@ -28,6 +28,7 @@ SCWeb.ui.Core = { SCWeb.ui.WindowManager.init(data), SCWeb.ui.SearchPanel.init(), SCWeb.ui.ExpertModePanel.init(), + SCWeb.ui.IntModePanel.init(data), SCWeb.ui.KeyboardHandler.init(SCWeb.ui.WindowManager), self.resolveElementsAddr('body') ).done(function () { diff --git a/client/js/Ui/intmodepanel.js b/client/js/Ui/intmodepanel.js new file mode 100644 index 00000000..0daba2d5 --- /dev/null +++ b/client/js/Ui/intmodepanel.js @@ -0,0 +1,48 @@ +SCWeb.ui.IntModePanel = { + init: function (data) { + var dfd = new jQuery.Deferred(); + var int_mode_identifier = 'ui_int_mode'; + this.int_mode_container_id = '#' + 'int_mode_container'; + var self = this; + + SCWeb.ui.SearchPanel.intmode.init_core(dfd, data); + + SCWeb.core.Server.resolveScAddr([int_mode_identifier], function (addrs) { + var int_mode_sc_addr = addrs[int_mode_identifier]; + if (int_mode_sc_addr) { + SCWeb.core.Server.resolveIdentifiers([int_mode_sc_addr], function (translation) { + $(self.int_mode_container_id + ' label.normalLabel'). + attr('sc_addr', int_mode_sc_addr).text(translation[int_mode_sc_addr]); + + SCWeb.core.EventManager.subscribe("translation/update", self, self.updateTranslation); + SCWeb.core.EventManager.subscribe("translation/get", self, function (objects) { + $(self.int_mode_container_id + ' [sc_addr]').each(function (index, element) { + objects.push($(element).attr('sc_addr')); + }); + }); + + dfd.resolve(); + }); + } + }); + + return dfd.promise(); + }, + + // ---------- Translation listener interface ------------ + updateTranslation: function (namesMap) { + // apply translation + $(this.int_mode_container_id + ' [sc_addr]').each(function (index, element) { + var addr = $(element).attr('sc_addr'); + if (namesMap[addr]) { + $(element).text(namesMap[addr]); + } + }); + }, + + updateCurrentLangugae : function() { + var cur_lang_addr = SCWeb.core.Translation.current_lang; + + + } +}; diff --git a/client/js/Ui/searchpanel.js b/client/js/Ui/searchpanel.js index 383a7c5d..d27421fa 100644 --- a/client/js/Ui/searchpanel.js +++ b/client/js/Ui/searchpanel.js @@ -1,12 +1,22 @@ const searchByKeyWord = (event, item) => { - if (item && item.addr) { + if (item.group === 'intmode') { + SCWeb.ui.SearchPanel.intmode.run_question(item); + } else if (item.addr) { SCWeb.core.Main.doDefaultCommand([item.addr]); + } else { + searchByIdentifier(item); } event.stopPropagation(); $('.typeahead').val(''); $('.tt-dropdown-menu').hide(); }; +const searchByIdentifier = (identifier) => { + SCWeb.core.Server.resolveScAddr([identifier], function (addrs) { + SCWeb.core.Main.doDefaultCommand([addrs[identifier]]); + }); +} + SCWeb.ui.SearchPanel = { init: function () { var dfd = new jQuery.Deferred(); @@ -24,26 +34,41 @@ SCWeb.ui.SearchPanel = { name: 'idtf', source: function (query, cb) { $('#search-input').addClass('search-processing'); - SCWeb.core.Server.findIdentifiersSubStr(query, function (data) { - keys = []; - - var addValues = function (key) { - var list = data[key]; - if (list) { - for (idx in list) { - var value = list[idx] - keys.push({name: value[1], addr: value[0], group: key}); + // TODO implement for rocksdb + keys = []; + + var nonintsearch = function() { + SCWeb.core.Server.findIdentifiersSubStr(query, function (data) { + var addValues = function (key) { + var list = data[key]; + if (list) { + for (idx in list) { + var value = list[idx] + keys.push({name: value[1], addr: value[0], group: key}); + } } } - } - addValues('sys'); - addValues('main'); - addValues('common'); + addValues('sys'); + addValues('main'); + addValues('common'); - cb(keys); - $('#search-input').removeClass('search-processing'); - }); + cb(keys); + $('#search-input').removeClass('search-processing'); + }) + }; + + if (SCWeb.core.IntModeEnabled) { + var intmode = SCWeb.ui.SearchPanel.intmode; + + if (intmode.timer !== null) + window.clearTimeout(intmode.timer); + + intmode.timer = window.setTimeout(() => { + intmode.process(keys, query, nonintsearch); + }, intmode.timeout_time); + } else + nonintsearch(); }, displayKey: 'name', templates: { @@ -53,6 +78,8 @@ SCWeb.ui.SearchPanel = { var html = ''; if (item.group === 'common') { return '

' + item.name + '

'; + } else if (item.group === 'intmode') { + return '

' + item.title + '

'; } else { var cl = 'glyphicon glyphicon-user'; if (item.group === 'sys') { @@ -60,7 +87,6 @@ SCWeb.ui.SearchPanel = { } return '

' + item.name + '

'; } - return '

' + item.name + '

'; } } } @@ -68,7 +94,7 @@ SCWeb.ui.SearchPanel = { searchByKeyWord(event, item); }).keypress(function (event) { if (event.which === 13) { - searchByKeyWord(event, keys[0]); + searchByKeyWord(event, $('#search-input').val()); } }); @@ -82,5 +108,493 @@ SCWeb.ui.SearchPanel = { return dfd.promise(); }, + + intmode : { + timer : null, + timeout_time : 1000, + languagesSysIdtfs : {}, + modules : {}, + enabled_modules : [], + precalculated_modules_info : { + /*module_name : { + lang_ru : true, //do run on this language + lang_en : false, + ... + }*/ + }, + cache : { + /*url : { + is_processed : true, + url : "", + module_name : "", + response : { + entities : { + entity_name : [ + { + value : "" + } + ] + }, + + intents : [ + { + intent : "", + confidence : 0.0 + } + ] + } + }*/ + }, + questions_addrs : {}, + special_addrs : { + nothing_found : { + idtf : "ui_int_mode_nothing_found", + addr : null + } + }, + current_lang_idtf : null, + + init_core : function(dfd, data) { + var get_sys = function (addr) { + scHelper.getSystemIdentifier(addr) + .done(function (res) { + SCWeb.ui.SearchPanel.intmode.languagesSysIdtfs[res] = addr; + + dfd.resolve(res); + }) + .fail(function () { + dfd.reject(); + }); + }; + + data.languages.forEach(function(lang_addr) { + get_sys(lang_addr); + }); + + //check what modules are to be enabled + var intmode = SCWeb.ui.SearchPanel.intmode; + var flag_elements_to_check = []; + var flags_and_modules = {}; + + for (var module_name in intmode.modules) { + var flag_element = intmode.modules[module_name].flag_element; + + if (flag_element === "") + intmode.enabled_modules.push(module_name); + else { + flag_elements_to_check.push(flag_element); + flags_and_modules[flag_element] = module_name; + } + } + + SCWeb.core.Server.resolveScAddr(flag_elements_to_check, function(addrs) { + flag_elements_to_check.forEach(function(flag_element) { + if (addrs[flag_element] !== undefined) + intmode.enabled_modules.push(flags_and_modules[flag_element]); + else + console.warn("[IntMode] The module '" + flags_and_modules[flag_element] + + "' was disabled because flag element `" + flag_element + "` doesn't exist"); + }); + + console.log("[IntMode] Enabled modules are: " + intmode.enabled_modules); + + //add question defaults + intmode.enabled_modules.forEach(function(module_name) { + var module = intmode.modules[module_name]; + + for (var def in module.question_defaults) { + module.questions.forEach(function(question) { + question[def] = module.question_defaults[def]; + }); + } + }); + + //extract addrs of all the question idtfs + var questions_idtfs = []; + var questions_idtfs_and_questions = {}; + + //warn: what if there're two questions (potential;y from diff. modules) which share the same name + intmode.enabled_modules.forEach(function(module_name) { + intmode.modules[module_name].questions.forEach(function(question) { + if (question.flags.is_enabled) { + questions_idtfs.push(question.question_idtf); + questions_idtfs_and_questions[question.question_idtf] = question; + } + }); + }); + + SCWeb.core.Server.resolveScAddr(questions_idtfs, function(addrs) { + questions_idtfs.forEach(function(question_idtf) { + if (addrs[question_idtf] !== undefined) + intmode.questions_addrs[question_idtf] = addrs[question_idtf]; + else { + questions_idtfs_and_questions[question_idtf].flags.is_enabled = false; + + console.warn("[IntMode] The question with `question_idtf`=" + question_idtf + + " was disabled because the idtf doesn't exist"); + } + }); + + //fill in precalculated modules info + intmode.enabled_modules.forEach(function(module_name) { + var info = {}; + + //by default don't run requests at all + for (var lang in intmode.modules[module_name].url_prefixes) { + info[lang] = false; + } + + //if there's at least one not disabled question then run requests for this lang + intmode.modules[module_name].questions.forEach(function(question) { + if (question.flags.is_enabled) + info[question.lang] = true; + }); + + intmode.precalculated_modules_info[module_name] = info; + }); + + var nothing_found_idtf = intmode.special_addrs.nothing_found.idtf; + SCWeb.core.Server.resolveScAddr([nothing_found_idtf], function(addrs) { + if (addrs[nothing_found_idtf] !== undefined) { + intmode.special_addrs.nothing_found.addr = addrs[nothing_found_idtf]; + } else + console.error("[IntMode] Couldn't find `" + nothing_found_idtf + "`. Badbad"); + + dfd.resolve(); + }); + }); + }); + }, + + process : function(keys, query, callback) { + var dfd = new jQuery.Deferred(); + var intmode = SCWeb.ui.SearchPanel.intmode; + + //get current language and its sys_idtf + //for each module: + // get according url prefix + // send request (if result isn't already in the cache) + // extract all intents (only if confidence fits) and all the pairs "entity_id=>value" + // save them into general arr of values and to map which associates values with module + //load addrs for that arr + //save everything to cache + //check all available questions for current language + var current_lang_idtf = null; + var current_lang = SCWeb.core.Translation.current_lang; + + for (var lang in intmode.languagesSysIdtfs) { + if (intmode.languagesSysIdtfs[lang] === current_lang) { + current_lang_idtf = lang; + + break; + } + } + + intmode.current_lang_idtf = current_lang_idtf; + + if (current_lang_idtf !== null) { + var requests_to_make = []; + + intmode.enabled_modules.forEach(function(module_name) { + var module_info = intmode.precalculated_modules_info[module_name]; + + //[current_lang] can be undefined + if (module_info[current_lang_idtf] === true) { + requests_to_make.push({ + module_name : module_name, + url_prefix : intmode.modules[module_name].url_prefixes[current_lang_idtf], + token : intmode.modules[module_name].tokens[current_lang_idtf] + }); + } + }); + + var results = {}; + + intmode.make_request(results, requests_to_make, query, function(results) { + intmode.process_results(results, callback, keys); + }); + } else + console.warn("[IntMode] Int mode won't start beacause there're no languages at all!"); + }, + + //if the requests would be running in parallel that would be cool + make_request : function(results, remained_requests, query, final_callback) { + if (remained_requests.length > 0) { + var intmode = SCWeb.ui.SearchPanel.intmode; + var request = remained_requests[remained_requests.length - 1]; + var url_prefix = request.url_prefix; + var module_name = request.module_name; + var url = url_prefix + query; + + if (intmode.cache[url] === undefined) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", url, true); + xhr.setRequestHeader("Authorization", request.token); + xhr.onload = function() { + results[module_name] = { + is_processed : false, + url : url, + response : JSON.parse(xhr.responseText), + module_name : module_name + } + remained_requests.pop(); + + intmode.make_request(results, remained_requests, query, final_callback); + }; + xhr.onerror = function() { + intmode.make_request(results, remained_requests, query, final_callback); + }; + xhr.send(); + } else { + results[module_name] = intmode.cache[url]; + remained_requests.pop(); + + intmode.make_request(results, remained_requests, query, final_callback); + } + } else + final_callback(results); + }, + + process_results : function(results, callback, keys) { + var entities_values = []; + + for (var mn in results) { + var result = results[mn]; + + if (!result.is_processed && result.response.entities !== undefined) { + for (var em in result.response.entities) { + var entity = result.response.entities[em]; + + entity.forEach(function(instance) { + entities_values.push(instance.body); + }); + } + } + } + + for (var mn in results) { + var result = results[mn]; + + if (!result.is_processed) { + //add cache entry + //extract intents + var intents = []; + if (result.response.intents !== undefined) { + result.response.intents.forEach(function(intent) { + var i = { + intent : intent.name, + confidence : intent.confidence + }; + + intents.push(i); + }); + } + + //extract entities + var entities = {}; + if (result.response.entities !== undefined) { + for (var entity in result.response.entities) { + var entity_obj = []; + + result.response.entities[entity].forEach(function(instance) { + var e = { + value : instance.body, + last_pos : instance.end, + from : instance.from + }; + + entity_obj.push(e); + }); + + entities[entity] = entity_obj; + } + } + + result.response = { + intents : intents, + entities : entities + }; + result.is_processed = true; + + SCWeb.ui.SearchPanel.intmode.cache[result.url] = result; + } + } + + SCWeb.ui.SearchPanel.intmode.select_questions(results, callback, keys); + }, + + select_questions : function(results, callback, keys) { + var intmode = SCWeb.ui.SearchPanel.intmode; + var final_questions = []; + var args_mapped_to_questions = {}; + + for (var mn in results) { + var result = results[mn]; + + //we've got results for a module + //check all available (not disabled) questions on this result + + var module = intmode.modules[result.module_name]; + + module.questions.forEach(function(question) { + if (question.flags.is_enabled && question.lang === intmode.current_lang_idtf) { + var args = intmode.check_question(result.response, question); + if (args !== false) { + final_questions.push(question); + args_mapped_to_questions[question.question_idtf] = args; + } + } + }); + } + + intmode.add_questions(final_questions, args_mapped_to_questions, callback, keys); + }, + + add_questions : function(questions, results, callback, keys) { + questions.forEach(function(question) { + var args = results[question.question_idtf]; + keys.push({ + group : "intmode", + title : question.translate(args), + question : question, + args : args + }); + }); + + callback(); + }, + + check_question : function(result, question) { + var intmode = SCWeb.ui.SearchPanel.intmode; + var args = []; + + //check intent + var matched_intent = false; + + for (var i = 0; i < result.intents.length; ++i) { + var _intent = result.intents[i]; + + if (_intent.intent === question.intent && + _intent.confidence >= question.minimal_confidence) { + + matched_intent = true; + break; + } + } + + if (!matched_intent) + return false; + + //check entities against arguments pattern + var args_count_requested = question.arguments.count; + var descriptors = question.arguments.descriptors; + var infinite_args = args_count_requested === -1; + + var entities_and_last_pos = {}; + + if (infinite_args && descriptors.length !== 1) + return false; + + var count_of_infinite_args = infinite_args ? result.entities[descriptors[0].entity].length : 0; + + /* + * Add system which calculates requested count of instances for each entity (let's the count is n), selects + * n most probable instances from them and uses only them to extract the arguments + * + * Such system would help in the case when the model is underteached and throws several entities where + * only one should be + */ + + for (var i = 0; i < (infinite_args ? count_of_infinite_args : descriptors.length); ++i) { + var descriptor = infinite_args ? descriptors[0] : descriptors[i]; + var last_pos = 0; + + if (entities_and_last_pos[descriptor.entity] !== undefined) + last_pos = entities_and_last_pos[descriptor.entity]; + + //find entity instance which begins after last_pos, increase last_pos + if (result.entities[descriptor.entity] !== undefined) { + var instance = intmode. + find_next_entity_instance(result.entities[descriptor.entity], last_pos); + + if (instance !== null || infinite_args) { + entities_and_last_pos[descriptor.entity] = instance.last_pos; + args.push(instance.value); + } else + return false; + } else + return false; + } + + return args; + }, + + find_next_entity_instance : function(instances, last_pos) { + var the_instance = null; + + for (var i = 0; i < instances.length; ++i) { + var instance = instances[i]; + + if (instance.last_pos >= last_pos && + (the_instance === null || instance.from <= the_instance.from)) + the_instance = instance; + } + + return instance; + }, + + run_question : function(question) { + console.log("[IntMode] Running `" + question.question.question_idtf + "` with args=" + question.args.toString()); + + var intmode = SCWeb.ui.SearchPanel.intmode; + var addrs = []; + + intmode.find_args_addrs(question.args, addrs, 0, function() { + SCWeb.core.Main.doCommand(intmode.questions_addrs[question.question.question_idtf], addrs); + }, + function(arg) { + console.warn("[IntMode] No sc-elements were found for idtf `" + arg + "`"); + SCWeb.core.Main.doDefaultCommand([intmode.special_addrs.nothing_found.addr]); + }); + }, + + find_args_addrs : function(args, addrs, index, success, failure) { + if (index < args.length) { + SCWeb.core.Server.findIdentifiersSubStr(args[index], function (data) { + var search = function (key) { + var list = data[key]; + + if (list) { + for (idx in list) { + var value = list[idx]; + + if (value[1] === args[index]) { + addrs.push(value[0]); + + break; + } + } + } + } + + var length = addrs.length; + + search('sys'); + + if (length === addrs.length) + search('main'); + + if (length === addrs.length) + search('common'); + + if (length !== addrs.length) + SCWeb.ui.SearchPanel.intmode.find_args_addrs(args, addrs, index + 1, success, failure); + else + failure(args[index]); + }); + } else + success(); + }, + }, }; diff --git a/client/static/components/css/common.css b/client/static/components/css/common.css index 3d9bbc9d..207e120b 100644 --- a/client/static/components/css/common.css +++ b/client/static/components/css/common.css @@ -483,6 +483,14 @@ div[class="tooltip-inner"] { padding-top: 15px; padding-bottom: 15px; } + +/* --- int mode checkbox --- */ +#int_mode_container { + padding-top: 15px; + padding-bottom: 15px; + margin-left: 10px; + } + /* The switch - the box around the slider */ .switch { position: relative; diff --git a/client/static/components/js/sc-int-mode.js b/client/static/components/js/sc-int-mode.js new file mode 100644 index 00000000..f8d60a30 --- /dev/null +++ b/client/static/components/js/sc-int-mode.js @@ -0,0 +1,181 @@ +window.__intmode_wrap = function(arg) { + return "" + arg + ""; +}; + +SCWeb.ui.SearchPanel.intmode.modules["module_ims"] = { + tokens : { + lang_ru : "Bearer GRMMPDROAGTOXPQT4NHOGIXW2IKQRO4Y", + lang_en : "Bearer CZAFPYDDJVTBJI5KQZC4AIZOQRHK2JBM" + }, + + url_prefixes : { + lang_ru : "https://api.wit.ai/message?v=20210514&q=", + lang_en : "https://api.wit.ai/message?v=20210330&q=" + }, + + flag_element : "ui_menu_view_full_semantic_neighborhood", //the module is always enabled if flag_element is empty + + question_defaults : { + minimal_confidence : 0.5, + arguments : { + count : 1, + descriptors : [ + { + entity : "wit$message_subject:message_subject" + } + ] + }, + flags : { + is_enabled : true + } + }, + + questions : [ + { + lang : "lang_en", + question_idtf : "ui_menu_view_full_semantic_neighborhood", + intent : "what_is", + translate : function(arguments) { + return "What is " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_en", + question_idtf : "ui_menu_view_authors", + intent : "who_is_author", + translate : function(arguments) { + return "Who is the author of " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_en", + question_idtf : "ui_menu_view_decomposition", + intent : "variants_of_decomposition", + translate : function(arguments) { + return "What are the variants of decomposition of " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_en", + question_idtf : "ui_menu_view_all_input_const_pos_arc_in_the_agreed_part_of_kb", + intent : "sets_contain_entity", + translate : function(arguments) { + return "What sets do contain " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_en", + question_idtf : "ui_menu_view_all_subclasses_in_quasybinary_relation", + intent : "particular_entities", + translate : function(arguments) { + return "Which entities are particular to " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_en", + question_idtf : "ui_menu_view_all_output_const_pos_arc_in_the_agreed_part_of_kb", + intent : "members_of_set", + translate : function(arguments) { + return "What are elements of " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_en", + question_idtf : "ui_menu_view_all_superclasses_in_quasybinary_relation", + intent : "general_entities", + translate : function(arguments) { + return "Which entities are general to " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_en", + question_idtf : "ui_menu_view_translation", + intent : "external_languages", + translate : function(arguments) { + return "What does " + __intmode_wrap(arguments[0]) + " look like in external languages?"; + } + }, + { + lang : "lang_en", + question_idtf : "ui_menu_view_all_identifiers", + intent : "external_identifiers", + translate : function(arguments) { + return "What are external identifiers of " + __intmode_wrap(arguments[0]) + "?"; + } + }, + + //russian versions + { + lang : "lang_ru", + question_idtf : "ui_menu_view_full_semantic_neighborhood", + intent : "what_is", + translate : function(arguments) { + return "Что такое " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_ru", + question_idtf : "ui_menu_view_authors", + intent : "who_is_author", + translate : function(arguments) { + return "Кто является автором " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_ru", + question_idtf : "ui_menu_view_decomposition", + intent : "variants_of_decomposition", + translate : function(arguments) { + return "Какие варианты декомпозиции существуют для " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_ru", + question_idtf : "ui_menu_view_all_input_const_pos_arc_in_the_agreed_part_of_kb", + intent : "sets_contain_entity", + translate : function(arguments) { + return "Элементом каких множеств является " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_ru", + question_idtf : "ui_menu_view_all_subclasses_in_quasybinary_relation", + intent : "particular_entities", + translate : function(arguments) { + return "Какие сущности являются частными относительно " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_ru", + question_idtf : "ui_menu_view_all_output_const_pos_arc_in_the_agreed_part_of_kb", + intent : "members_of_set", + translate : function(arguments) { + return "Какие элементы содержатся в " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_ru", + question_idtf : "ui_menu_view_all_superclasses_in_quasybinary_relation", + intent : "general_entities", + translate : function(arguments) { + return "Какие сущности являются общими относительно " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_ru", + question_idtf : "ui_menu_view_translation", + intent : "external_languages", + translate : function(arguments) { + return "Как выглядит " + __intmode_wrap(arguments[0]) + " на внешних языках?"; + } + }, + { + lang : "lang_ru", + question_idtf : "ui_menu_view_all_identifiers", + intent : "external_identifiers", + translate : function(arguments) { + return "Какие внешние идентификаторы соответствуют " + __intmode_wrap(arguments[0]) + "?"; + } + } + ] +}; diff --git a/client/templates/base.html b/client/templates/base.html index dee300ba..005a99ce 100644 --- a/client/templates/base.html +++ b/client/templates/base.html @@ -90,6 +90,24 @@ + +
- - + -
@@ -158,7 +178,7 @@

IMSOSTIS

- + Copyright © 2012 - 2018 OSTIS @@ -178,7 +198,6 @@

IMSOSTIS

$('#windows-list').click(function () { $('#static-window-container').toggle(); - $(this).find('span').toggleClass('glyphicon-resize-small').toggleClass('glyphicon-resize-full'); }); SCWeb.ui.Locker.show(); diff --git a/client/templates/components.html b/client/templates/components.html index 2313038f..4e3839af 100644 --- a/client/templates/components.html +++ b/client/templates/components.html @@ -5,6 +5,7 @@ + diff --git a/components/intmode/modules/IntModule_Ims.js b/components/intmode/modules/IntModule_Ims.js new file mode 100644 index 00000000..f8d60a30 --- /dev/null +++ b/components/intmode/modules/IntModule_Ims.js @@ -0,0 +1,181 @@ +window.__intmode_wrap = function(arg) { + return "" + arg + ""; +}; + +SCWeb.ui.SearchPanel.intmode.modules["module_ims"] = { + tokens : { + lang_ru : "Bearer GRMMPDROAGTOXPQT4NHOGIXW2IKQRO4Y", + lang_en : "Bearer CZAFPYDDJVTBJI5KQZC4AIZOQRHK2JBM" + }, + + url_prefixes : { + lang_ru : "https://api.wit.ai/message?v=20210514&q=", + lang_en : "https://api.wit.ai/message?v=20210330&q=" + }, + + flag_element : "ui_menu_view_full_semantic_neighborhood", //the module is always enabled if flag_element is empty + + question_defaults : { + minimal_confidence : 0.5, + arguments : { + count : 1, + descriptors : [ + { + entity : "wit$message_subject:message_subject" + } + ] + }, + flags : { + is_enabled : true + } + }, + + questions : [ + { + lang : "lang_en", + question_idtf : "ui_menu_view_full_semantic_neighborhood", + intent : "what_is", + translate : function(arguments) { + return "What is " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_en", + question_idtf : "ui_menu_view_authors", + intent : "who_is_author", + translate : function(arguments) { + return "Who is the author of " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_en", + question_idtf : "ui_menu_view_decomposition", + intent : "variants_of_decomposition", + translate : function(arguments) { + return "What are the variants of decomposition of " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_en", + question_idtf : "ui_menu_view_all_input_const_pos_arc_in_the_agreed_part_of_kb", + intent : "sets_contain_entity", + translate : function(arguments) { + return "What sets do contain " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_en", + question_idtf : "ui_menu_view_all_subclasses_in_quasybinary_relation", + intent : "particular_entities", + translate : function(arguments) { + return "Which entities are particular to " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_en", + question_idtf : "ui_menu_view_all_output_const_pos_arc_in_the_agreed_part_of_kb", + intent : "members_of_set", + translate : function(arguments) { + return "What are elements of " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_en", + question_idtf : "ui_menu_view_all_superclasses_in_quasybinary_relation", + intent : "general_entities", + translate : function(arguments) { + return "Which entities are general to " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_en", + question_idtf : "ui_menu_view_translation", + intent : "external_languages", + translate : function(arguments) { + return "What does " + __intmode_wrap(arguments[0]) + " look like in external languages?"; + } + }, + { + lang : "lang_en", + question_idtf : "ui_menu_view_all_identifiers", + intent : "external_identifiers", + translate : function(arguments) { + return "What are external identifiers of " + __intmode_wrap(arguments[0]) + "?"; + } + }, + + //russian versions + { + lang : "lang_ru", + question_idtf : "ui_menu_view_full_semantic_neighborhood", + intent : "what_is", + translate : function(arguments) { + return "Что такое " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_ru", + question_idtf : "ui_menu_view_authors", + intent : "who_is_author", + translate : function(arguments) { + return "Кто является автором " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_ru", + question_idtf : "ui_menu_view_decomposition", + intent : "variants_of_decomposition", + translate : function(arguments) { + return "Какие варианты декомпозиции существуют для " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_ru", + question_idtf : "ui_menu_view_all_input_const_pos_arc_in_the_agreed_part_of_kb", + intent : "sets_contain_entity", + translate : function(arguments) { + return "Элементом каких множеств является " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_ru", + question_idtf : "ui_menu_view_all_subclasses_in_quasybinary_relation", + intent : "particular_entities", + translate : function(arguments) { + return "Какие сущности являются частными относительно " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_ru", + question_idtf : "ui_menu_view_all_output_const_pos_arc_in_the_agreed_part_of_kb", + intent : "members_of_set", + translate : function(arguments) { + return "Какие элементы содержатся в " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_ru", + question_idtf : "ui_menu_view_all_superclasses_in_quasybinary_relation", + intent : "general_entities", + translate : function(arguments) { + return "Какие сущности являются общими относительно " + __intmode_wrap(arguments[0]) + "?"; + } + }, + { + lang : "lang_ru", + question_idtf : "ui_menu_view_translation", + intent : "external_languages", + translate : function(arguments) { + return "Как выглядит " + __intmode_wrap(arguments[0]) + " на внешних языках?"; + } + }, + { + lang : "lang_ru", + question_idtf : "ui_menu_view_all_identifiers", + intent : "external_identifiers", + translate : function(arguments) { + return "Какие внешние идентификаторы соответствуют " + __intmode_wrap(arguments[0]) + "?"; + } + } + ] +};