Skip to content

Instantly share code, notes, and snippets.

View kasei's full-sized avatar

Gregory Todd Williams kasei

View GitHub Profile
#!/usr/bin/env perl
=head1 NAME
attean-sparql-list-operators.plpl - Example of using list functions and a new EXPLODE operator in SPARQL
=head1 DESCRIPTION
New extension functions operating over literals with datatype `ex:List`:
@kasei
kasei / sparql-list-function-support.md
Last active August 7, 2022 00:28
SPARQL strawman for functions and operators over lists

I took a few hours to hack up a proof-of-concept for this SPARQL use-case:

Another related example. Given these column values

  • project: 123
  • PI_IDS: 1858722 (contact); 1883064; 3150248;
  • PI_NAMEs: BUCK, JOCHEN (contact); LEVIN, LONNY R; VISCONTI, PABLO E.;

I want it to converted to this

@kasei
kasei / json-ld-issue-reset-protected-term.md
Last active January 6, 2020 19:44
JSON-LD 1.1 issue with test for overriding protected terms in property-scoped context

Test tpr19 includes a property-scoped context that includes a null value:

    "protected2": {
      "@id": "ex:protected2",
      "@context": [
        null,
        {
          "protected1": "ex:protected3"
 }
@kasei
kasei / json-ld-issue-graph-simplification.md
Last active January 3, 2020 04:51
JSON-LD 1.1 issue with double-`@graph` expansion

In Expansion step 20, expanded result maps that contain only a @graph entry are simplified:

If result is a map that contains only an @graph entry, set result that value.

In test t0081, I believe the expansion of the "input" key:

  "input": {
    "@graph": {
 "value": "x"
@kasei
kasei / json-ld-issue-list-optimization.md
Created January 2, 2020 17:22
Issue with JSON-LD 1.1 optimization of @list

Expansion step 13.11 says:

If container mapping includes @list and expanded value is not already a list object, convert expanded value to a list object by first setting it to an array containing only expanded value if it is not already an array, and then by setting it to a map containing the key-value pair @list-expanded value.

In test t0004 I believe the recursive Expansion call in 13.9 for the mylist1 key will set expanded value to:

[
	{
 "@list": []
@kasei
kasei / json-ld-index-issue.md
Last active January 6, 2020 19:40
JSON-LD 1.1 issue with handling @Index container mappings

Regarding test tpi07, I can't figure out how the @index handling should result in the expected test output. Expansion algorithm step 13.8.3.7.2 seems like relevant code:

If container mapping includes @index, index key is not @index, item does not have an entry @index and expanded index is not @none, initialize index property values to the concatenation of expanded index with any existing values of index key in item. Add the key-value pair (expanded index-index property values) to item. If item is a value object, it MUST NOT contain any extra properties; an invalid value object error has been detected and processing is aborted.

@kasei
kasei / json-ld-drop-langauge-only-issue.md
Last active December 24, 2019 20:34
JSON-LD 1.1 issue with dropping @language-only objects

Test t0008:

{
  "@context": {
    "ex": "http://example.org/vocab#"
  },
  "@id": "http://example.org/test",
  "ex:test": { "@value": "test",  "@language": "en" },
 "ex:drop-lang-only": { "@language": "en" },
@kasei
kasei / sparql-star-wikidata-example.sh
Created August 8, 2019 22:57
SPARQL* syntax used for Wikidata reification
$ docker pull kasei/swift-sparql-syntax:sparql-star-wikidata
$ docker run -t kasei/swift-sparql-syntax:sparql-star-wikidata sparql-parser wikidata -S 'SELECT ?speed ?qualifierLabel WHERE { << wd:Q183 wdt:P3086 ?speed >> pq:P3005 ?qualifier ; SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } }'
SELECT ?speed ?qualifierLabel WHERE {
_:_blank.b1 <http://www.wikidata.org/prop/statement/P3086> ?speed .
<http://www.wikidata.org/entity/Q183> <http://www.wikidata.org/prop/P3086> _:_blank.b1 .
<http://www.wikidata.org/entity/Q183> <http://www.wikidata.org/prop/direct/P3086> ?speed .
_:_blank.b1 <http://www.wikidata.org/prop/qualifier/P3005> ?qualifier .
SERVICE <http://wikiba.se/ontology#label>
{
<http://www.bigdata.com/rdf#serviceParam> <http://wikiba.se/ontology#language> "en" .
@kasei
kasei / sparql-star-wikidata.rq
Created August 8, 2019 22:57
SPARQL* syntax used for Wikidata reification
# Using SPARQL* syntax:
SELECT ?speed ?qualifierLabel WHERE {
<< wd:Q183 wdt:P3086 ?speed >>
pq:P3005 ?qualifier ;
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
# becomes Wikidata reification:
SELECT ?speed ?qualifierLabel WHERE {
wd:Q183
@kasei
kasei / rdflib-jsonld-bug.py
Last active June 4, 2019 16:17
Bug in RDFLib JSON-LD code that drops embedded blank nodes
#!/usr/bin/env python3
from rdflib.serializer import Serializer
from rdflib import Graph, URIRef, BNode, Literal
from rdflib.namespace import FOAF, DCTERMS
g = Graph()
spatial = BNode()
g.add((URIRef('http://example.org/thing'), DCTERMS.spatial, spatial))
g.add((spatial, FOAF.name, Literal('California')))