From f47b97f65666ca5ea09cd542c8196c46159d6bfb Mon Sep 17 00:00:00 2001 From: Emerson Rocha Date: Sun, 4 Apr 2021 15:32:18 -0300 Subject: [PATCH] v0.8.5 started; hxlm-js (hdp #18, lisp #18), the javascript version _starts_ to undestand HDP; part of the code inspired on https://tags.etica.ai --- hxlm-js/bootstrapper/hdp-aux.js | 45 +++++++++++++++++++++--- hxlm-js/bootstrapper/hdp-minimam.mjs | 39 ++++++++++++++++----- hxlm-js/index.html | 52 ++++++++++++++++++++++++++-- hxlm/core/__init__.py | 2 +- setup.cfg | 2 +- 5 files changed, 124 insertions(+), 16 deletions(-) diff --git a/hxlm-js/bootstrapper/hdp-aux.js b/hxlm-js/bootstrapper/hdp-aux.js index a0e23e8..ebdc2b3 100644 --- a/hxlm-js/bootstrapper/hdp-aux.js +++ b/hxlm-js/bootstrapper/hdp-aux.js @@ -1,11 +1,22 @@ -console.log('hdp-aux.js') - -// TODO: https://wesbos.com/template-strings-html +/** + * @license Public Domain + * @author Emerson Rocha + * @description HDPAux is not actually part of the HDP conventions, but + * contains some code to help with interface. + * @created 2021 + * + * This work is done with love and special attention to details for the + * international community that does not have in English its mother language. + * Part of the JavaScript scripts are based on + * / + **/ +// TODO: look at https://en.wikipedia.org/wiki/Semantic_bootstrapping class HDPAux { _DEBUG = false + static _console_QS = '.hdp-console-items' constructor(res) { @@ -61,7 +72,7 @@ class HDPAux { // console.log('console_html', wrapper_el, output) // console.log('testeste', out, this._console_html_template()) if (wrapper_el) { - wrapper_el.innerHTML = output + wrapper_el.innerHTML + wrapper_el.innerHTML = output + wrapper_el.innerHTML // wrapper_el.appendChild(output) // https://highlightjs.org/usage/ if (hljs && hljs.highlightAll) { @@ -74,4 +85,30 @@ class HDPAux { } // this_._DEBUG && console.log('console_html out', out) } + + /** + * Who I am + * + * Trivia: + * - 'Quis sum?' is 'who I am' in Latin + * - 'mea linguam' is 'my (natural) language' in Latin + * - 'mea linguam fontem' is 'my source (natural) language' in Latin + * - 'mea linguam et alli' needs revision. (its an array) + * - Code: + * - Based on the English version ais-ethics-tags.js (https://tags.etica.ai) + * @returns {Object} + */ + static quis_sum() { + let resultatum = {}; + resultatum.meaLinguam = navigator.language || navigator.userLanguage; + resultatum.meaLinguamEtAliiFontem = navigator.languages || [resultatum.meaLinguam]; + resultatum.meaLinguamEtAlii = []; + resultatum.meaLinguamEtAliiFontem.forEach(function (lang) { + let wdLang = lang.split('-'); + if (resultatum.meaLinguamEtAlii.indexOf(wdLang[0]) === -1) { + resultatum.meaLinguamEtAlii.push(wdLang[0]); + } + }) + return resultatum + } } \ No newline at end of file diff --git a/hxlm-js/bootstrapper/hdp-minimam.mjs b/hxlm-js/bootstrapper/hdp-minimam.mjs index c9113ad..f6139a1 100644 --- a/hxlm-js/bootstrapper/hdp-minimam.mjs +++ b/hxlm-js/bootstrapper/hdp-minimam.mjs @@ -29,18 +29,39 @@ class HDPMiniman { version = "0.8.5" _DEBUG = false + + /** + * @typedef {Object} EGO Current user context + * @example {'meaLinguam': 'pt', meaLinguamEtAlii: ['pt'], meaLinguamEtAliiFontem: ['pt_BR']} + */ + EGO = null + + /** + * @typedef {String} FONTEM_LKG Path to JSON LKG + */ FONTEM_LKG = null + + /** + * @typedef {String} FONTEM_VKG Path to JSON VKG + */ FONTEM_VKG = null + + /** + * @typedef {Object} ONTOLOGIA_LKG Parsed result of FONTEM_LKG + */ ONTOLOGIA_LKG = null - ONTOLOGIA_VKG = null - // constructor(ONTOLOGIA_LKG, ONTOLOGIA_VKG) { + /** + * @typedef {Object} ONTOLOGIA_VKG Parsed result of FONTEM_VKG + */ + ONTOLOGIA_VKG = null /** - * - * @param res Object {'LKG': "/path/lkg.json", 'VKG': "/path/vkg.json"} + * + * @param res {Object} {'LKG': "/path/lkg.json", 'VKG': "/path/vkg.json"} + * @param ego {Object} Current user context */ - constructor(res) { + constructor(res, ego) { // console.log(res) if (typeof HDP_DEBUG !== 'undefined') { @@ -48,6 +69,9 @@ class HDPMiniman { console.log('HDPMiniman HDP_DEBUG !== undefined', HDP_DEBUG) } + this.EGO = ego + + // console.log('this.EGO', ego, this.EGO) if (res && res.LKG) { self.FONTEM_LKG = res.LKG @@ -235,8 +259,8 @@ class HDPMiniman { let topself = self let topthis = this // console.log('explanare, self._DEBUG', self._DEBUG) - if (self._DEBUG){ - console.log('explanare', { + if (self._DEBUG) { + console.log('explanare', { 'FONTEM_LKG': topself.FONTEM_LKG, 'FONTEM_VKG': topself.FONTEM_VKG, 'ONTOLOGIA_LKG': topself.ONTOLOGIA_LKG, @@ -292,4 +316,3 @@ class HDPMiniman { // let hdp = new HDPMiniman() // hdp.explanare(); - diff --git a/hxlm-js/index.html b/hxlm-js/index.html index e9a9869..853862a 100644 --- a/hxlm-js/index.html +++ b/hxlm-js/index.html @@ -45,11 +45,17 @@

JavaScript


 // let HDP_DEBUG = true
 bootstrapping = HDPMiniman.bootstrapping()
-hdp = new HDPMiniman(bootstrapping)
+ego = HDPAux.quis_sum()
+
+// HDP Language _bootstrapping_ based on you (_ego_)
+hdp = new HDPMiniman(bootstrapping, ego)
 
 // Output the current version of this library
 console.log("HDP Miniman version:", hdp.version)
 
+// Output what we can automate for you
+console.log("HDPMiniman.EGO :", hdp.EGO)
+
 // This return an quick overview
 hdp.explanare().then(console.log).catch(console.error)
 
@@ -66,7 +72,35 @@ 

console.log

+
+

About

+

+ See project at + https://github.com/EticaAI/HXL-Data-Science-file-formats. +

+

+ Part of this code is based on + https://tags.etica.ai/. +

+

License

+

+ The EticaAI has + dedicated the work to the + public domain + by waiving all of their rights to the work worldwide + under copyright law, including all related and neighboring + rights, to the extent + allowed by law. You can copy, modify, distribute and perform + the work, even for commercial purposes, all without asking + permission. +

+
+ + +