In our implementation each widget receives a "default" value when initialized. In the case of literals, this is a literal with the lexical form "", i.e. the empty string. In the case of URIs this is an URI node with "" as its URI. This approach means that these scoring rules can apply relatively consistently.

Having said this, the score functions in our implementation also receive a second argument, which is metadata about the 'field', which is basically the collection of applicable property shapes for that property/path. Some widgets do use that metadata to make further choices in cases where the node isn't sufficient to make a decision.

Examples:

BlankNodeViewer.score = (value, field) => {
returnvalue.isBlankNode() ? 1 : 0;
};


The only widgets that use the 'field' above are dash:Editors:

BooleanSelectEditor.score = (value, field) => {
if(value.dt == 'boolean') {
return10;
    }
if(field.isObjectProperty) {
return0;
    }
if(field.hasDT('boolean')) {
return10;
    }
if(field.hasAnyDT()) {
return0;
    }
returnnull;
};


DatePickerEditor.score = (value, field) => {
returnvalue.dt == 'date' ? 10 : field && field.hasDT('date') ? 5 : 0;
};

DateTimePickerEditor.score = (value, field) => {
returnvalue.dt == 'dateTime' ? 10 : field && field.hasDT('dateTime') ? 5 : 0;
};

EnumSelectEditor.score = (value, field) => {
returnfield && field.enumValues ? 10 : 0;
};

FromConceptSchemeEditor.score = (value, field) => {
if(field && field.hasAnyDT()) {
// Unsuitable for datatype fields
return0;
    }
// We don't have enough info here to decide so leave the choice to users
returnnull;
};

OWLManchesterSyntaxEditor.score = (value, field) => {
if (
        !field.path.isInverse &&
        (field.path.predicate == 'http://www.w3.org/2000/01/rdf-schema#domain' ||
field.path.predicate == 'http://www.w3.org/2000/01/rdf-schema#range' ||
field.path.predicate == 'http://www.w3.org/2000/01/rdf-schema#subClassOf' ||
field.path.predicate == 'http://www.w3.org/2002/07/owl#disjointWith' ||
field.path.predicate == 'http://www.w3.org/2002/07/owl#equivalentClass')
    ) {
if (value.isBlankNode()) {
return50;
        } else {
returnnull;
        }
    } else {
return0;
    }
};

TextAreaEditor.score = (value, field) => {
if (value.isString()) {
if (field && field.singleLine === true) {
return0;
        } elseif (field && field.singleLine === false) {
return20; // Prefer over single line editors
        } elseif(DisplayUtil.containsLineBreak(value.lex) && field.singleLine !== false) {
return20; // Prefer over single line editors if line breaks exist
        } else {
return5;
        }
    } elseif (field.hasDT('string')) {
return2;
    }
elseif(field.hasCustomDatatype()) {
returnnull;
    } else {
return0;
    }
};

TextAreaWithLangEditor.score = (value, field) => {
if (value.isLangString() || (field && field.isStringOrLangString())) {
if (field && field.singleLine === true) {
return0;
        } elseif (field && field.singleLine === false) {
return15; // Prefer over single line editors
        } elseif(DisplayUtil.containsLineBreak(value.lex) && field.singleLine !== false) {
return15; // Prefer over single line editors if line breaks exist
        } else {
return5;
        }
    } elseif (field && field.hasDT('langString') && !field.singleLine) {
return5;
    } else {
return0;
    }
};

TextFieldWithLangEditor.score = (value, field) => {
if (value.isLangString() || (field && field.isStringOrLangString())) {
return10;
    } elseif (field && field.hasDT('langString') && !field.singleLine) {
return5;
    } else {
return0;
    }
};

TimeEditor.score = (value, field) => {
returnvalue.dt == 'time' ? 15 : field && field.hasDT('time') ? 5 : 0;
};

URIEditor.score = (value, field) => {
if (value.isURI()) {
if (field.nodeKind && field.nodeKind.label == 'IRI' && field.isObjectProperty && field.classes.length == 0) {
return10;
        } else {
returnnull;
        }
    } else {
return0;
    }
};

I have made small updates to the forms.html online doc to clarify this (and added dash:DateTimePicker which we have implemented in the meantime).

Holger


On 12/06/2020 18:51, Tomasz Pluskiewicz wrote:
Hi

I am implementing a SHACL form builder in JavaScript and intended to have DASH integrated by default.

I have a little difficulty with the scoring system. Let's take the simplest text field as example. The spec says

  * 10 if the value is a literal that is neither rdf:langString nor
    xsd:boolean
  * 0 otherwise

First question is in general about the rules which mention a "value". This applies only to existing triples in the dataset at the time the form is initialised, correct? For example

|
# score 10
<#me> rdfs:label "Tomasz Pluskiewicz" .

# score 0
<#me> rdfs:label "Tomasz Pluskiewicz"@pl .
|

I think this is missing a rule for adding new objects for a property. Such as when a user clicks a (+) button. In that case the property shape is the only information available as there is no "value" yet. The example snippet does show a "sh:datatype xsd:string" but it's not mentioned in the score rules for the text field. A bit of a grey area?

Best,
Tom
--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/14c15fa7-448a-4d00-9c9e-ca957e12f56co%40googlegroups.com <https://groups.google.com/d/msgid/topbraid-users/14c15fa7-448a-4d00-9c9e-ca957e12f56co%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
You received this message because you are subscribed to the Google Groups "TopBraid 
Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/topbraid-users/a2c9f4b5-882b-c34a-a594-f0702d32a8b1%40topquadrant.com.

Reply via email to