Skip to content

Instantly share code, notes, and snippets.

View jindrichmynarz's full-sized avatar

Jindřich Mynarz jindrichmynarz

View GitHub Profile
@jindrichmynarz
jindrichmynarz / cedr_download.sh
Created October 10, 2016 12:31
Stažení dumpů CEDRu
#!/bin/bash
#
# Stažení dumpů CEDRu
set -e
# URL SPARQL endpointu CEDRu
ENDPOINT="http://cedropendata.mfcr.cz/c3lod/cedr/sparql"
# SPARQL dotaz pro získání URL dumpů
@jindrichmynarz
jindrichmynarz / fuse_by_key.sparql
Created October 6, 2016 06:40
Fuse resources by key
PREFIX : <http://example.com/>
DELETE {
?r ?outP ?outO .
?inS ?inP ?r .
}
INSERT {
?sampleR ?outP ?outO .
?inS ?inP ?sampleR .
}
@jindrichmynarz
jindrichmynarz / fuse_less_described.sparql
Last active October 6, 2016 20:53
Fuse subset descriptions
PREFIX : <http://example.com/>
DELETE {
?r1 ?outP ?outO .
?inS ?inP ?r1 .
}
INSERT {
?inS ?inP ?r2 .
}
WHERE {
@jindrichmynarz
jindrichmynarz / fuse_equivalent_hashes.sparql
Created October 5, 2016 16:47
Fuse equivalent resources by hash
PREFIX : <http://example.com/>
DELETE {
?r ?outP ?outO .
?inS ?inP ?r .
}
WHERE {
{
SELECT (SAMPLE(?r) AS ?sampleR) ?hash
WHERE {
@jindrichmynarz
jindrichmynarz / data.ttl
Created October 5, 2016 16:43
Sample dataset for RDF data fusion
@prefix : <http://example.com/> .
:r1 a :C ;
:name "a" .
:r2 a :C ;
:name "a" .
:r3 a :C ;
:name "a" ;
@jindrichmynarz
jindrichmynarz / blank_nodes_to_hash_iris.sparql
Created October 5, 2016 16:36
Blank nodes to hash-based IRIs
DELETE {
?bnode ?outP ?outO .
?inS ?inP ?bnode .
}
INSERT {
?iri ?outP ?outO .
?inS ?inP ?iri .
}
WHERE {
{
@jindrichmynarz
jindrichmynarz / fill_down_blanks.sparql
Created September 29, 2016 20:18
Fill down blanks in CSV/RDF
# Fills empty cells with values of their nearest preceding non-empty cells.
# For performance reasons, the function is restricted to :column_1.
# Even so, it takes about 10 minutes for 10k row CSV.
PREFIX : <http://localhost/>
PREFIX csvw: <http://www.w3.org/ns/csvw#>
INSERT {
?row :column_1 ?column_1 .
}
@jindrichmynarz
jindrichmynarz / code_list_diff.sh
Last active September 23, 2016 09:50
Diff versions of a code list
#!/bin/bash
#
# Compute the diff between SKOS code lists.
# Usage: ./code_list_diff.sh [-h|--help] old_version new_version
set -e
shopt -s extglob
V1=$1
V2=$2
@jindrichmynarz
jindrichmynarz / element_tree.xsl
Created September 20, 2016 20:39
Summarizes hierarchical structure of an XML document
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output encoding="UTF-8" indent="yes" method="xml" />
<xsl:template match="/*">
<xsl:element name="{name()}">
<xsl:call-template name="group"/>
</xsl:element>
</xsl:template>
@jindrichmynarz
jindrichmynarz / match_code_lists.sh
Created August 25, 2016 14:33
Match concepts from two SKOS code lists
#!/bin/bash
#
# Match concepts from two SKOS code lists.
# Usage: match_code_lists.sh code_list_1.ttl code_list_2.ttl
# Outputs RDF in Turtle with the links found.
set -e
shopt -s extglob
die () {