Open greenTara opened 4 years ago
We start with implementation of tuples because there are less design decisions that need to be made. Specifications:
The javascript is in the myng directory of the repository, in index.html
https://github.com/RuleML/deliberation-ruleml/blob/1.03-psoa/myng/index.html
The existing facet for Term Sequences is a good template for a set of radio buttons.
<td class="facet"> <span class="facet-head">Term Sequences: <br /> Number of Terms <br /></span> (Select One) <ol>
<li><input type="radio" name="termseq" onclick="checkAll(this.form)" /> None </li>
<li>
<input type="radio" name="termseq" onclick="checkAll(this.form)" /> Unary (Zero
or One) </li>
<li>
<input type="radio" name="termseq" onclick="checkAll(this.form)" /> Binary (Zero
or Two) </li>
<li>
<input type="radio" name="termseq" onclick="checkAll(this.form)" /> Unary/Binary (Zero
to Two) </li>
<li>
<input type="radio" name="termseq" onclick="checkAll(this.form)" /> Variably Polyadic (Zero
or More) </li>
</ol>
</td>
In the function "intialize-form", the initial selection of the radio button is set:
function initializeForm(LanguageForm) {
// One option must be checked for radio buttons
...
if (!(
LanguageForm.termseq[0].checked *
LanguageForm.termseq[1].checked *
LanguageForm.termseq[2].checked *
LanguageForm.termseq[3].checked *
LanguageForm.termseq[4].checked)) {
// initialize to Variably Polyadic
LanguageForm.termseq[4].checked = true;
}
In the function "clearOthers", the minimal or empty option is selected:
function clearOthers(LanguageForm) {
//Set other radio buttons
LanguageForm.termseq[0].checked = true;
In the function "fillOthers", the maximal element is selected:
function fillOthers(LanguageForm) {
//Set other radio buttons
LanguageForm.termseq[4].checked = true;
The radio button selection is transformed into a portion of myng code in the function
function get_ts(LanguageForm) {
var ts = 0;
for (var i = 0; i <= 4; i = i + 1) {
if (LanguageForm.termseq[i].checked) {
switch (i) {
case 0:
ts = 0;
break;
case 1:
ts = 1;
break;
case 2:
ts = 2;
break;
case 3:
ts = 3;
break;
default:
ts = 7;
break;
}
}
}
return ts;
}
In this function, the query string containing the myng code is built:
function constructParams2(bb, df, ts, lng, propo, implies, terms, quant,
expr, serial) {
var params = "?";
...
params = params + "&termseq=x" + ts.toString(16);
In this function, the myng code is extracted from a complete query string:
function myngCode(params) {
// kind of inverse to multi-argument constructParams
var code = "myng";
//extract each parameter value from query string
...
var ts = getParam(params, "termseq");
...
code = code + "-a" + ts;
In the function checkAll, interactions between selections can be created:
function checkAll(LanguageForm) {
...
// If quantification is allowed and
// term sequences are variably polyadic, then
// positional rest variables are available
if (datalogAndUp && LanguageForm.termseq[4].checked) {
LanguageForm.quant2.removeAttribute('disabled');
} else {
LanguageForm.quant2.checked = false;
LanguageForm.quant2.disabled = "disabled";
}
When adding new functionality to the MYNG GUI, it is necessary to coordinate with the MYNG PHP engine:
https://github.com/RuleML/deliberation-ruleml/blob/1.03-psoa/relaxng/schema_rnc.php
For example, the termseq segment of the myng code is utilized as follows:
$termseq_unary = 0;
$termseq_binary = 1;
$termseq_ternary_plus = 2;
...
$enableTermseq_unary = extractBit($btermseq, $termseq_unary);
$enableTermseq_binary = extractBit($btermseq, $termseq_binary);
$enableTermseq_ternary_plus = extractBit($btermseq, $termseq_ternary_plus);
while the tuple features correspond to this:
$terms_tupdep = 14;
$terms_tup = 15;
...
$needTupDep = extractBit($bterms, $terms_tupdep);
...
$needTup = extractBit($bterms, $terms_tup);
Tool suggestion:
Tests:
Anchor language functionality is implemented in this function:
function anchorXSD(LanguageForm) {
//bindatagroundfact_normal
var bb = 1;
var df = 7;
var ts = 2;
var lng = 1;
var propo = parseInt("3cf", 16);
var implies = 6;
var terms = parseInt("f0f", 16);
var quant = 1;
var expr = 0;
var serial = parseInt("4c", 16);
var comp = compareTo(LanguageForm, bb, df, ts, lng,
propo, implies, terms, quant, expr, serial );
if ( comp) {
return "bindatagroundfact_normal";
}
...
The checkboxes for PSOA tuple features will (most likely) appear in a new "facet". The dependent slot feature is more complicated because it is related to the existing (independent) slot feature.