Comunica
LiaScript template for interactive SPARQL-queries and playing around with the semantic web technologies
Install / Use
/learn @LiaTemplates/ComunicaREADME
Comunica - Template
--{{0}}--
This document defines some basic LiaScript-macros for dealing and experimenting with the semantic web-technologies, such as querying SPARQL and or dealing with RDF in the form of turtle. Others are about to come. This template is mainly based on Comunica an open-source knowledge graph querying framework. I hope in the future, there will be more functions available. At the moment it is possible to execute and edit code-blocks with SPARQL queries.
Try it on LiaScript:
https://liascript.github.io/course/?https://raw.githubusercontent.com/liaTemplates/Comunica/main/README.md
See the project on Github:
https://github.com/liaTemplates/Comunica
--{{1}}--
There are three ways to use this template. The easiest way is to use the
import statement and the url of the raw text-file of the master branch or any
other branch or version. But you can also copy the required functionionality
directly into the header of your Markdown document, see therefor the
last slide. And of course, you could also clone this project
and change it, as you wish.
{{1}}
-
Load the macros via
import: https://raw.githubusercontent.com/LiaTemplates/Comunica/0.0.3/README.md -
Copy the definitions into your Project
-
Clone this repository on GitHub
Minimal Requirements
--{{0}}--
What is actually needed to make your Markdown code-snippets with SPARQL executable and editable? Not much, simply add the following comment to the head of your Markdown document.
<!--
import: https://raw.githubusercontent.com/LiaTemplates/Comunica/0.0.3/README.md
-->
# Title
...
--{{1}}--
And finally attach the macros/functions, which are defined by this document, to the end of a code-block. You can define as much code-blocks as you want.
{{1}}
``` sparql
# source: https://fragments.dbpedia.org/2015/en
SELECT ?s ?p ?o WHERE {
?s ?p <http://dbpedia.org/resource/Ukraine>.
?s ?p ?o
} LIMIT 100
```
@Comunica.SPARQL
Macros
--{{0}}--
Currently you can use two macros, which can also be tweaked a bit. We will describe them both within this section.
@Comunica.SPARQL@Comunica.RDF_SPARQL
@Comunica.SPARQL
--{{0}}--
Add the macro @Comunica.SPARQL to the end of your
SPARQL query to make it executable and
editable. You can add as much blocks as you want to.
``` sparql
# source: https://fragments.dbpedia.org/2015/en
SELECT ?s ?p ?o WHERE {
?s ?p <http://dbpedia.org/resource/Ukraine>.
?s ?p ?o
} LIMIT 10
```
@Comunica.SPARQL
--{{1}}--
The result will look as follows, you can execute it, change the code of the query and go back and forth between your version.
{{1}}
# source: https://fragments.dbpedia.org/2015/en
SELECT ?s ?p ?o WHERE {
?s ?p <http://dbpedia.org/resource/Ukraine>.
?s ?p ?o
} LIMIT 10
@Comunica.SPARQL
--{{2}}--
And to some extend also the errors are propagated to the user.
{{2}}
# source: https://fragments.dbpedia.org/2015/en
SELECT ?s ?p ?o WHERE {
?s ?p <http://dbpedia.org/resource/Ukraine>
?s ?p ?o
} LIMIT 10
@Comunica.SPARQL
Sources
--{{0}}--
As you have seen earlier, it is possible by you and by your user to define the sources for your query. Simply add one or multiple comments of the following form into your code-block. If you use a one-liner, your sources have to be separated by one space.
# source: https://fragments.dbpedia.org/2015/en
# source: https://www.rubensworks.net https://ruben.verborgh.org/profile/
SELECT ?s ?p ?o WHERE {
?s ?p <http://dbpedia.org/resource/Belgium>.
?s ?p ?o
} LIMIT 100
@Comunica.SPARQL
Formats
--{{0}}--
It is possible to define different output formats, simply by adding an comment
of the form # format: _.
# format: table
# source: https://fragments.dbpedia.org/2015/en
SELECT ?s ?p ?o WHERE {
?s ?p <http://dbpedia.org/resource/Ukraine>.
?s ?p ?o
} LIMIT 5
@Comunica.SPARQL
--{{1}}--
The default format is currently table, however, you can overwrite this by one
of the following media types. All possible formats are defined
here. However,
currently it only possible to use a subset of them, which are highlighted in the
table.
{{1}}
| Media type | Supported | Description | | --------------------------------- |:---------:| -------------------------------------------------------------------------------- | | `application/
Related Skills
node-connect
350.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
