-
Notifications
You must be signed in to change notification settings - Fork 0
Lowering Grounding Examples
ThibaultGerrier edited this page May 27, 2020
·
3 revisions
Currently I have the custom spp function split (not like described in the mindlab deliverable) into one that returns only one item and the other that returns a list of items (spp vs sppList). I'm not sure if this will stay like this. In this document they are split.
input action:
{
"@context": {
"@vocab": "http://schema.org/"
},
"@type": "Action",
"actionStatus": "http://schema.org/ActiveActionStatus",
"agent": {
"@type": "Person",
"name": "John"
},
"object": [
{
"@type": "Place",
"name": "top",
"description": "its nice"
},
{
"@type": "Place",
"name": "bot",
"description": "its bad"
}
]
}
wanted output:
hello John
{
"name": "John",
"val": [
{
"name": "top",
"desc": "its nice"
},
{
"name": "top",
"description": "its bad"
}
]
}
<root>
<name>John</name>
<val name="top">its nice</val>
<val name="bot">its bad</val>
</root>
hello {{ spp ":agent/:name" }}
json bit tricky with arrays, might add a helper function later
{
"name": "{{ spp ":agent/:name" }}",
"val": [
{{#each (sppList ":object") }}
{
"name": "{{ spp this ":name"}}",
"desc": "{{ spp this ":description"}}"
}{{#unless @last}},{{/unless}}
{{/each}}
]
}
<root>
<name>{{ spp ":agent/:name" }}</name>
{{#each (sppList ":object") }}
<val name="{{ spp this ":name" }}">{{ spp this ":description" }}</val>
{{/each}}
</root>
"hello " || fn:spp(":agent/:name")
map {
"name": fn:spp(":agent/:name"),
"val": array {
fn:for-each(fn:sppList(":object"), function($id){
map {
"name": fn:spp($id, ":name"),
"desc": fn:spp($id, ":description")
}
})
}
}
<root>
<name>{fn:spp(":agent/:name")}</name>
{fn:for-each(fn:sppList(":object"), function($id){
<val name="{fn:spp($id, ":name")}">{fn:spp($id, ":description")}</val>
})}
</root>
`Hello ${spp(':agent/:name')}`
({
"name": spp(":agent/:name"),
"val": sppList(":object").map(id => ({
"name": spp(id, ":name"),
"desc": spp(id, ":description")
}))
})
`<root>
<name>${spp(":agent/:name")}</name>
${sppList(":object").map(id =>
`<val name="${spp(id, ":name")}">${spp(id, ":description")}</val>`
).join('')}
</root>`