eyereasoner / eye

Euler Yet another proof Engine
https://eyereasoner.github.io/eye/
MIT License
124 stars 17 forks source link

Inline function arguments #70

Closed tpluscode closed 1 year ago

tpluscode commented 1 year ago

I have this rule, which uses some built-ins

@prefix ch: <https://schema.ld.admin.ch/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix string: <http://www.w3.org/2000/10/swap/string#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix schema: <http://schema.org/>.

{
    ?canton a ch:Canton .
    ?canton schema:alternateName ?name .
    ?name string:lowerCase ?nameLower .
    ( "http://classifications.data.admin.ch/canton/" ?nameLower ) string:concatenation ?c .
    ?classification log:uri ?c .
}
=>
{
    ?canton owl:sameAs ?classification .
} .

Is it possible to inline variables ?nameLower and ?c?

josd commented 1 year ago

You can write the above as

@prefix ch: <https://schema.ld.admin.ch/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix string: <http://www.w3.org/2000/10/swap/string#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix schema: <http://schema.org/>.

ch:abc a ch:Canton;
    schema:alternateName "Abc".

{
    ?canton a ch:Canton .
    ?canton schema:alternateName ?name .
    ?classification log:uri ( "http://classifications.data.admin.ch/canton/" ?name!string:lowerCase )!string:concatenation .
}
=>
{
    ?canton owl:sameAs ?classification .
} .

giving

ch:abc owl:sameAs <http://classifications.data.admin.ch/canton/abc>.
tpluscode commented 1 year ago

Fantastic!

The exclamation mark is a standard n3 feature?

josd commented 1 year ago

Yes it is, see https://pr-preview.s3.amazonaws.com/w3c/N3/pull/117.html#paths

tpluscode commented 1 year ago

Thank you!