Skip to content

Commit

Permalink
v0.8.5 started; hxlm-js (hdp #18, lisp #18), the javascript version _…
Browse files Browse the repository at this point in the history
…starts_ to undestand HDP; part of the code inspired on https://tags.etica.ai
  • Loading branch information
fititnt committed Apr 4, 2021
1 parent 9e20848 commit f47b97f
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 16 deletions.
45 changes: 41 additions & 4 deletions hxlm-js/bootstrapper/hdp-aux.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
console.log('hdp-aux.js')

// TODO: https://wesbos.com/template-strings-html
/**
* @license Public Domain
* @author Emerson Rocha <rocha(at)ieee.org>
* @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
* <https://github.com/fititnt/ais-ethics-tags> / <https://tags.etica.ai/>
**/

// TODO: look at https://en.wikipedia.org/wiki/Semantic_bootstrapping

class HDPAux {

_DEBUG = false

static _console_QS = '.hdp-console-items'

constructor(res) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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
}
}
39 changes: 31 additions & 8 deletions hxlm-js/bootstrapper/hdp-minimam.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,49 @@
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') {
self._DEBUG = HDP_DEBUG
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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -292,4 +316,3 @@ class HDPMiniman {
// let hdp = new HDPMiniman()

// hdp.explanare();

52 changes: 50 additions & 2 deletions hxlm-js/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,17 @@ <h3>JavaScript</h3>
<pre><code class="lang-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)

Expand All @@ -66,7 +72,35 @@ <h3>console.log</h3>
</div>
</div>

<footer lang="en">
<h2>About</h2>
<p>
See project at <a href="https://github.com/EticaAI/HXL-Data-Science-file-formats">
https://github.com/EticaAI/HXL-Data-Science-file-formats</a>.
</p>
<p>
Part of this code is based on
<a href="https://tags.etica.ai/">https://tags.etica.ai/</a>.
</p>
<h2>License</h2>
<p>
The <a href="https://github.com/EticaAI">EticaAI</a> has
dedicated the work to the
<a href="/EticaAI/HXL-Data-Science-file-formats/blob/main/UNLICENSE">public domain</a>
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.
</p>
</footer>
</main>

<!--
After here is the logic part of this page.
-->

<!-- JQuery, Boostrap -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
Expand All @@ -89,11 +123,17 @@ <h3>console.log</h3>

// 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)

Expand Down Expand Up @@ -122,6 +162,14 @@ <h3>console.log</h3>
true // This means that the code should show instead of be colapsed
)

HDPAux.console_html(
["HDPMiniman.EGO :",
hdp.EGO],
'lang-json',
'<code>console.log("HDPMiniman.EGO :", hdp.EGO)</code>',
true // This means that the code should show instead of be colapsed
)

hdp.explanare('LKG').then(function (data) {
HDPAux.console_html(data, 'lang-json', "<code>hdp.explanare('LKG').then(console.log).catch(console.error)</code>")
}).catch(console.error)
Expand Down
2 changes: 1 addition & 1 deletion hxlm/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# Users need to explicitly call this
# import hxlm.core.compliance

__version__ = "0.8.4"
__version__ = "0.8.5"

# To simplify documentation, we're always load this constant when end users do
# import hxlm as HXLm
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# - https://en.wikipedia.org/wiki/Toolchain
# name = hxlm-base-eticaai # New temporary name 'hdp-toolchain' on 2021-03-30
name = hdp-toolchain
version = 0.8.4
version = 0.8.5
author = Emerson Rocha
author_email = [email protected]
description = HDP Declarative Programming (working draft)
Expand Down

0 comments on commit f47b97f

Please sign in to comment.