Skip to content

Instantly share code, notes, and snippets.

Jindřich Mynarz jindrichmynarz

View GitHub Profile
@jindrichmynarz
jindrichmynarz / indirect_wikidata.rq
Created Apr 22, 2020
Construct indirect Wikidata links used by DBpedia
View indirect_wikidata.rq
# Run at the German DBpedia SPARQL endpoint: http://de.dbpedia.org/sparql
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT ?dbpedia
WHERE {
BIND (<http://www.wikidata.org/entity/Q1418856> AS ?wikidata)
BIND (strafter(str(?wikidata), "http://www.wikidata.org/entity/") AS ?qid)
BIND (iri(concat("http://wikidata.dbpedia.org/resource/", ?qid)) AS ?indirect_wikidata)
?dbpedia owl:sameAs ?indirect_wikidata .
@jindrichmynarz
jindrichmynarz / wikitrends.py
Last active Jul 7, 2019
Displays a graph of the most visited entities in Wikipedia, in Bash and Python versions
View wikitrends.py
#!/usr/bin/env python3
from argparse import ArgumentParser, ArgumentTypeError
from datetime import date, datetime, timedelta
import json
import re
from string import Template
import urllib.parse
import urllib.request
import webbrowser
@jindrichmynarz
jindrichmynarz / count_class_instances_from_lod_laundromat.sh
Last active Aug 18, 2018
Count class instances from LOD Laundromat
View count_class_instances_from_lod_laundromat.sh
#!/usr/bin/env bash
#
# A demo script that retrieves counts of class instances from LOD Laundromat datasets
# Usage:
# Reads a list of newline separated class IRIs either from its first argument or standard input.
# $ count_class_instances_from_lod_laundromat.sh < classes.txt
#
# Caveat:
# Since we use an old-school shell script, class IRIs that contain special characters,
# like %-encoding or commas will break the CSV output.
@jindrichmynarz
jindrichmynarz / obfuscate_rdf.ru
Created Jun 5, 2018
Basic obfuscation of RDF data using SHA hashes + UUID salt
View obfuscate_rdf.ru
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
###############
# Create salt #
###############
INSERT {
GRAPH :mappings {
@jindrichmynarz
jindrichmynarz / cbd.rq
Created Feb 24, 2018
Recursive concise bounded description
View cbd.rq
# SPARQL 1.1 implementation of concise bounded description (<https://www.w3.org/Submission/CBD>).
PREFIX : <http://example.com/>
PREFIX non: <http://non/>
CONSTRUCT {
:resource ?p1 ?r1 .
?r2 ?p2 ?r3 .
}
WHERE {
@jindrichmynarz
jindrichmynarz / split_urls.ru
Created Aug 22, 2017
Split strings in pure SPARQL
View split_urls.ru
# Solution from: <http://answers.semanticweb.com/questions/19162/split-and-trim-strings-in-sparql/27544>
PREFIX schema: <http://schema.org/>
DELETE {
?s schema:url ?urls .
}
INSERT {
?s schema:url ?url .
}
@jindrichmynarz
jindrichmynarz / generate_rdf.rq
Created Apr 7, 2017
Generate 0 to 10 random RDF triples
View generate_rdf.rq
PREFIX : <http://localhost/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
CONSTRUCT {
?s ?p ?o .
}
WHERE {
# Generate 0 to 10 triples
VALUES ?n { 0 1 2 3 4 5 6 7 8 9 10 }
View cedr_download.sh
#!/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ů
View fuse_by_key.sparql
PREFIX : <http://example.com/>
DELETE {
?r ?outP ?outO .
?inS ?inP ?r .
}
INSERT {
?sampleR ?outP ?outO .
?inS ?inP ?sampleR .
}
View fuse_less_described.sparql
PREFIX : <http://example.com/>
DELETE {
?r1 ?outP ?outO .
?inS ?inP ?r1 .
}
INSERT {
?inS ?inP ?r2 .
}
WHERE {
You can’t perform that action at this time.