Questions about DASH scoring system

39 views
Skip to first unread message

Tomasz Pluskiewicz

unread,
Jun 12, 2020, 4:54:23 AM6/12/20
to TopBraid Suite Users
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

Holger Knublauch

unread,
Jun 14, 2020, 8:23:31 PM6/14/20
to topbrai...@googlegroups.com

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 = (valuefield=> {
    return value.isBlankNode() ? 1 : 0;
};


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

BooleanSelectEditor.score = (valuefield=> {
    if(value.dt == 'boolean') {
        return 10;
    }
    if(field.isObjectProperty) {
        return 0;
    }
    if(field.hasDT('boolean')) {
        return 10;
    }
    if(field.hasAnyDT()) {
        return 0;
    }
    return null;
};


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

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

EnumSelectEditor.score = (valuefield=> {
    return field && field.enumValues ? 10 : 0;
};

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

OWLManchesterSyntaxEditor.score = (valuefield=> {
    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()) {
            return 50;
        } else {
            return null;
        }
    } else {
        return 0;
    }
};

TextAreaEditor.score = (valuefield=> {
    if (value.isString()) {
        if (field && field.singleLine === true) {
            return 0;
        } else if (field && field.singleLine === false) {
            return 20// Prefer over single line editors
        } else if(DisplayUtil.containsLineBreak(value.lex) && field.singleLine !== false) {
            return 20// Prefer over single line editors if line breaks exist
        } else {
            return 5;
        }
    } else if (field.hasDT('string')) {
        return 2;
    }
    else if(field.hasCustomDatatype()) {
        return null;
    } else {
        return 0;
    }
};

TextAreaWithLangEditor.score = (valuefield=> {
    if (value.isLangString() || (field && field.isStringOrLangString())) {
        if (field && field.singleLine === true) {
            return 0;
        } else if (field && field.singleLine === false) {
            return 15// Prefer over single line editors
        } else if(DisplayUtil.containsLineBreak(value.lex) && field.singleLine !== false) {
            return 15// Prefer over single line editors if line breaks exist
        } else {
            return 5;
        }
    } else if (field && field.hasDT('langString') && !field.singleLine) {
        return 5;
    } else {
        return 0;
    }
};

TextFieldWithLangEditor.score = (valuefield=> {
    if (value.isLangString() || (field && field.isStringOrLangString())) {
        return 10;
    } else if (field && field.hasDT('langString') && !field.singleLine) {
        return 5;
    } else {
        return 0;
    }
};

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

URIEditor.score = (valuefield=> {
    if (value.isURI()) {
        if (field.nodeKind && field.nodeKind.label == 'IRI' && field.isObjectProperty && field.classes.length == 0) {
            return 10;
        } else {
            return null;
        }
    } else {
        return 0;
    }
};

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
--
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 topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/14c15fa7-448a-4d00-9c9e-ca957e12f56co%40googlegroups.com.

Tomasz Pluskiewicz

unread,
Jun 15, 2020, 5:59:13 AM6/15/20
to TopBraid Suite Users
Ah, yes, I realise that I eventually implemented it similarly with the default value because always added for new values so indeed the selection process is the same for existing and new objects.

Could you link to a diff of what you changed in forms.html?
To unsubscribe from this group and stop receiving emails from it, send an email to topbrai...@googlegroups.com.

Holger Knublauch

unread,
Jun 15, 2020, 6:09:17 PM6/15/20
to topbrai...@googlegroups.com


On 15/06/2020 19:59, Tomasz Pluskiewicz wrote:
Ah, yes, I realise that I eventually implemented it similarly with the default value because always added for new values so indeed the selection process is the same for existing and new objects.

Could you link to a diff of what you changed in forms.html?

Attached

Holger


To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/01450f1d-ed27-40a3-a10d-19b9b70b00bao%40googlegroups.com.
patch.txt

Tomasz Pluskiewicz

unread,
Jul 13, 2020, 5:52:14 AM7/13/20
to TopBraid Suite Users
By the way, I just notice that there is dash:DateTimePicker in the published DASH vocabulary

Holger Knublauch

unread,
Jul 13, 2020, 6:13:53 PM7/13/20
to topbrai...@googlegroups.com

Hi Tom,

I assume you meant "there is *no* dash:DateTimePicker" declared. Should be fixed now.

Thanks,
Holger

Tomek Pluskiewicz

unread,
Jul 14, 2020, 1:16:23 AM7/14/20
to topbrai...@googlegroups.com
Of course 😅

Thank you

Sent from Nine

From: Holger Knublauch <hol...@topquadrant.com>
Sent: Tuesday, 14 July 2020 00:13
To: topbrai...@googlegroups.com
Subject: Re: [topbraid-users] Questions about DASH scoring system
You received this message because you are subscribed to a topic in the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and all its topics, send an email to topbraid-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages