{"id":20660992,"url":"https://github.com/liatemplates/communica","last_synced_at":"2025-06-15T03:08:47.599Z","repository":{"id":107256830,"uuid":"417458334","full_name":"LiaTemplates/Communica","owner":"LiaTemplates","description":"LiaScript template for interactive SPARQL-queries and playing around with the semantic web technologies","archived":false,"fork":false,"pushed_at":"2021-10-15T11:18:52.000Z","size":1764,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-17T12:16:34.396Z","etag":null,"topics":["knowledge-graph","liascript","liascript-template","markdown","oer","rdf","semantic-web","sparql"],"latest_commit_sha":null,"homepage":"https://liascript.github.io/course/?https://raw.githubusercontent.com/liaTemplates/Communica/main/README.md","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LiaTemplates.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-15T10:25:31.000Z","updated_at":"2024-07-04T18:01:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"0225d8f0-36f1-4d80-be69-2e5e5d9aa7c8","html_url":"https://github.com/LiaTemplates/Communica","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaTemplates%2FCommunica","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaTemplates%2FCommunica/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaTemplates%2FCommunica/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaTemplates%2FCommunica/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LiaTemplates","download_url":"https://codeload.github.com/LiaTemplates/Communica/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242788017,"owners_count":20185203,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["knowledge-graph","liascript","liascript-template","markdown","oer","rdf","semantic-web","sparql"],"created_at":"2024-11-16T19:06:44.728Z","updated_at":"2025-03-10T04:25:11.094Z","avatar_url":"https://github.com/LiaTemplates.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\nauthor:   André Dietrich\n\nemail:    LiaScript@web.de\n\nversion:  0.0.2\n\nlogo:     https://semanticweb.cs.vu.nl/R/sparql_hollywood/sparql_hollywood_files/Screen-Shot-2012-09-28-at-20.27.12.png\n\nlanguage: en\n\nnarrator: US English Female\n\ncomment:  A macro library for trying and playing with SPARQL and RDF that is\n          based on Communica.\n\nscript:   https://cdn.jsdelivr.net/gh/liatemplates/communica@0.0.2/dist/index.js\n\n@Communica.SPARQL\n\u003cscript\u003e\n  function output(ok, message) {\n    if (ok) send.lia(message)\n    else {\n      let errMessage = []\n      let err = message.match(/Parse error on line (\\d+)[^\\n]\\n((?:.|\\n)+)/)\n\n      if (err.length \u003e= 3) {\n        errMessage = [[{\n          row : parseInt(err[1]) - 1,\n          column : 1,\n          text : err[2],\n          type : \"error\"\n        }]]\n      }\n\n      send.lia(message, errMessage, false)\n    }\n  }\n\n  window.RDF.query(`@input`, output, [] )\n\n  \"LIA: wait\"\n\u003c/script\u003e\n@end\n\n@Communica.RDF_SPARQL\n\u003cscript\u003e\n  function output(ok, message) {\n    if (ok) send.lia(message)\n    else {\n      let errMessage = []\n      let err = message.match(/Parse error on line (\\d+)[^\\n]\\n((?:.|\\n)+)/)\n\n      if (err.length \u003e= 3) {\n        errMessage = [[], [{\n          row : parseInt(err[1]) - 1,\n          column : 1,\n          text : err[2],\n          type : \"error\"\n        }]]\n      }\n\n      send.lia(message, errMessage, false)\n    }\n  }\n\n  window.RDF.parse.rdf(`@input`).then((e) =\u003e {\n    window.RDF.query(`@input(1)`, output, [ e ] )\n  })\n\n  \"LIA: wait\"\n\u003c/script\u003e\n@end\n\n--\u003e\n\n# Communica - Template\n\n                          --{{0}}--\nThis document defines some basic [LiaScript](https://LiaScript.github.io)-macros\nfor dealing and experimenting with the semantic web-technologies, such as\nquerying [SPARQL](https://en.wikipedia.org/wiki/SPARQL) and or dealing with\n[RDF](https://en.wikipedia.org/wiki/Resource_Description_Framework) in the form\nof [turtle](https://en.wikipedia.org/wiki/Turtle_%28syntax%29). Others are about\nto come. This template is mainly based on [Communica](https://comunica.dev) an\nopen-source knowledge graph querying framework. I hope in the future, there will\nbe more functions available. At the moment it is possible to execute and edit\ncode-blocks with SPARQL queries.\n\n__Try it on LiaScript:__\n\nhttps://liascript.github.io/course/?https://raw.githubusercontent.com/liaTemplates/Communica/main/README.md\n\n__See the project on Github:__\n\nhttps://github.com/liaTemplates/Communica\n\n                         --{{1}}--\nThere are three ways to use this template. The easiest way is to use the\n`import` statement and the url of the raw text-file of the master branch or any\nother branch or version. But you can also copy the required functionionality\ndirectly into the header of your Markdown document, see therefor the\n[last slide](#implementation). And of course, you could also clone this project\nand change it, as you wish.\n\n                           {{1}}\n1. Load the macros via\n\n   `import: https://raw.githubusercontent.com/LiaTemplates/Communica/0.0.2/README.md`\n\n2. Copy the definitions into your Project\n\n3. Clone this repository on GitHub\n\n## Minimal Requirements\n\n                         --{{0}}--\nWhat is actually needed to make your Markdown code-snippets with\n[SPARQL](https://en.wikipedia.org/wiki/SPARQL) executable and editable? Not\nmuch, simply add the following comment to the head of your Markdown document.\n\n``` markdown\n\u003c!--\nimport: https://raw.githubusercontent.com/LiaTemplates/Communica/0.0.2/README.md\n--\u003e\n\n# Title\n\n...\n```\n\n                         --{{1}}--\nAnd finally attach the macros/functions, which are defined by this document, to\nthe end of a code-block. You can define as much code-blocks as you want.\n\n\n                           {{1}}\n```` markdown\n``` sparql\n# source: https://fragments.dbpedia.org/2015/en\n\nSELECT ?s ?p ?o WHERE {\n  ?s ?p \u003chttp://dbpedia.org/resource/Ukraine\u003e.\n  ?s ?p ?o\n} LIMIT 100\n```\n@Communica.SPARQL\n````\n\n\n## Macros\n\n                          --{{0}}--\nCurrently you can use two macros, which can also be tweaked a bit. We will\ndescribe them both within this section.\n\n1. `@Communica.SPARQL`\n2. `@Communica.RDF_SPARQL`\n\n\n### `@Communica.SPARQL`\n\n                          --{{0}}--\nAdd the macro `@Communica.SPARQL` to the end of your\n[SPARQL](https://en.wikipedia.org/wiki/SPARQL) query to make it executable and\neditable. You can add as much blocks as you want to.\n\n```` markdown\n``` sparql\n# source: https://fragments.dbpedia.org/2015/en\n\nSELECT ?s ?p ?o WHERE {\n  ?s ?p \u003chttp://dbpedia.org/resource/Ukraine\u003e.\n  ?s ?p ?o\n} LIMIT 10\n```\n@Communica.SPARQL\n````\n\n                          --{{1}}--\nThe result will look as follows, you can execute it, change the code of the\nquery and go back and forth between your version.\n\n                            {{1}}\n``` sparql\n# source: https://fragments.dbpedia.org/2015/en\n\nSELECT ?s ?p ?o WHERE {\n  ?s ?p \u003chttp://dbpedia.org/resource/Ukraine\u003e.\n  ?s ?p ?o\n} LIMIT 10\n```\n@Communica.SPARQL\n\n\n                          --{{2}}--\nAnd to some extend also the errors are propagated to the user.\n\n                            {{2}}\n``` sparql\n# source: https://fragments.dbpedia.org/2015/en\n\nSELECT ?s ?p ?o WHERE {\n  ?s ?p \u003chttp://dbpedia.org/resource/Ukraine\u003e\n  ?s ?p ?o\n} LIMIT 10\n```\n@Communica.SPARQL\n\n#### Sources\n\n                          --{{0}}--\nAs you have seen earlier, it is possible by you and by your user to define the\nsources for your query. Simply add one or multiple comments of the following\nform into your code-block. If you use a one-liner, your sources have to be\nseparated by one space.\n\n``` sparql\n# source: https://fragments.dbpedia.org/2015/en\n# source: https://www.rubensworks.net https://ruben.verborgh.org/profile/\n\nSELECT ?s ?p ?o WHERE {\n?s ?p \u003chttp://dbpedia.org/resource/Belgium\u003e.\n?s ?p ?o\n} LIMIT 100\n```\n@Communica.SPARQL\n\n\n#### Formats\n\n                          --{{0}}--\nIt is possible to define different output formats, simply by adding an comment\nof the form `# format: _`.\n\n``` sparql\n# format: table\n# source: https://fragments.dbpedia.org/2015/en\n\nSELECT ?s ?p ?o WHERE {\n?s ?p \u003chttp://dbpedia.org/resource/Ukraine\u003e.\n?s ?p ?o\n} LIMIT 5\n```\n@Communica.SPARQL\n\n                          --{{1}}--\nThe default format is currently `table`, however, you can overwrite this by one\nof the following media types. All possible formats are defined\n[here](https://comunica.dev/docs/query/advanced/result_formats/). However,\ncurrently it only possible to use a subset of them, which are highlighted in the\ntable.\n\n                            {{1}}\n| Media type                        | Supported | Description                                                                      |\n| --------------------------------- |:---------:| -------------------------------------------------------------------------------- |\n| `application/json`                |    ✅     | A custom, simplified JSON result format.                                         |\n| `simple`                          |    ✅     | A custom, text-based result format.                                              |\n| `application/sparql-results+json` |    ✅     | The [SPARQL/JSON](https://www.w3.org/TR/sparql11-results-json) results format.   |\n| `application/sparql-results+xml`  |    ❌     | The [SPARQL/XML](https://www.w3.org/TR/rdf-sparql-XMLres) results format.        |\n| `text/csv`                        |    ✅     | The [SPARQL/CSV](https://www.w3.org/TR/sparql11-results-csv-tsv) results format. |\n| `text/tab-separated-values`       |    ✅     | The [SPARQL/TSV](https://www.w3.org/TR/sparql11-results-csv-tsv) results format. |\n| `stats`                           |    ❌     | A custom results format for testing and debugging.                               |\n| `table`                           |    ✅     | A text-based visual table result format.                                         |\n| `tree`                            |    ❌     | A tree-based result format for GraphQL-LD result compacting.                     |\n| `application/trig`                |    ❌     | The [TriG](https://www.w3.org/TR/trig) RDF serialization.                        |\n| `application/n-quads`             |    ❌     | The [N-Quads](https://www.w3.org/TR/n-quads) RDF serialization.                  |\n| `text/turtle`                     |    ❌     | The [Turtle](https://www.w3.org/TR/turtle) RDF serialization.                    |\n| `application/n-triples`           |    ❌     | The [N-Triples](https://www.w3.org/TR/n-triples) RDF serialization.              |\n| `text/n3`                         |    ❌     | The [Notation3](https://www.w3.org/TeamSubmission/n3) serialization.             |\n| `application/ld+json`             |    ❌     | The [JSON-LD](https://json-ld.org) RDF serialization.                            |\n\n\n### `@Communica.RDF_SPARQL`\n\n                          --{{0}}--\nIt is possible also to define your own files and to query them, by combining two\nMarkdown-blocks in conjunction. The first contains your turtle file, while the\nsecond code-block contains your query.\n\n```` markdown\n``` turtle       Turtle\n@prefix :     \u003chttp://www.example.org/sample.rdfs#\u003e .\n@prefix rdf:  \u003chttp://www.w3.org/1999/02/22-rdf-syntax-ns#\u003e .\n@prefix rdfs: \u003chttp://www.w3.org/2000/01/rdf-schema#\u003e.\n\n:Dog      rdfs:subClassOf :Animal.\n:Person   rdfs:subClassOf :Animal.\n\n:hasChild rdfs:range :Animal;\n          rdfs:domain :Animal.\n:hasSon   rdfs:subPropertyOf :hasChild.\n\n:Max      a :Dog.\n:Abel     a :Person.\n:Adam     a :Person;\n            :hasSon :Abel.\n```\n``` sparql      -SPARQL-Query\nSELECT * {\n  ?s ?p ?o\n} LIMIT 5\n```\n@Communica.RDF_SPARQL\n````\n\n                          --{{1}}--\nThe text behind the language definition is used as a title for your code-block,\nwhereby a starting `+` or `-` define, wheather the editor view should be opened\nor closed.\n\n                            {{1}}\n``` turtle       Turtle\n@prefix :     \u003chttp://www.example.org/sample.rdfs#\u003e .\n@prefix rdf:  \u003chttp://www.w3.org/1999/02/22-rdf-syntax-ns#\u003e .\n@prefix rdfs: \u003chttp://www.w3.org/2000/01/rdf-schema#\u003e.\n\n:Dog      rdfs:subClassOf :Animal.\n:Person   rdfs:subClassOf :Animal.\n\n:hasChild rdfs:range :Animal;\n          rdfs:domain :Animal.\n:hasSon   rdfs:subPropertyOf :hasChild.\n\n:Max      a :Dog.\n:Abel     a :Person.\n:Adam     a :Person;\n            :hasSon :Abel.\n```\n``` sparql      -SPARQL-Query\n# format: simple\n# source: https://fragments.dbpedia.org/2015/en\n\nSELECT * {\n  ?s ?p ?o\n} LIMIT 5\n```\n@Communica.RDF_SPARQL\n\n\n                          --{{2}}--\nIt is still possible to add different sources or to change the output format, as\ndescribed before.\n\n## Implementation\n\n                          --{{0}}--\nAll the functionionality is defined within the main-comment of this document. It\nmakes use of the typescript-functions defined in `src/index.ts`, which defines a\nglobal object `ẁindow.RDF`.\n\n``` html\nscript:   dist/index.js\n\n@Communica.SPARQL\n\u003cscript\u003e\n  function output(ok, message) {\n    if (ok) send.lia(message)\n    else {\n      let errMessage = []\n      let err = message.match(/Parse error on line (\\d+)[^\\n]\\n((?:.|\\n)+)/)\n\n      if (err.length \u003e= 3) {\n        errMessage = [[{\n          row : parseInt(err[1]) - 1,\n          column : 1,\n          text : err[2],\n          type : \"error\"\n        }]]\n      }\n\n      send.lia(message, errMessage, false)\n    }\n  }\n\n  window.RDF.query(`@input`, output, [] )\n\n  \"LIA: wait\"\n\u003c/script\u003e\n@end\n\n@Communica.RDF_SPARQL\n\u003cscript\u003e\n  function output(ok, message) {\n    if (ok) send.lia(message)\n    else {\n      let errMessage = []\n      let err = message.match(/Parse error on line (\\d+)[^\\n]\\n((?:.|\\n)+)/)\n\n      if (err.length \u003e= 3) {\n        errMessage = [[], [{\n          row : parseInt(err[1]) - 1,\n          column : 1,\n          text : err[2],\n          type : \"error\"\n        }]]\n      }\n\n      send.lia(message, errMessage, false)\n    }\n  }\n\n  window.RDF.parse.rdf(`@input`).then((e) =\u003e {\n    window.RDF.query(`@input(1)`, output, [ e ] )\n  })\n\n  \"LIA: wait\"\n\u003c/script\u003e\n@end\n```\n\n                          --{{1}}--\nIf you want to build this project by your own, then follow the following\ninstructions:\n\n                            {{1}}\n``` bash\n$ git clone https://github.com/LiaTemplates/Communica\n\n$ cd Communica\n\n$ git checkout dev\n\n$ npm i\n\n$ npm run build\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliatemplates%2Fcommunica","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliatemplates%2Fcommunica","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliatemplates%2Fcommunica/lists"}