Skip to content

Instantly share code, notes, and snippets.

View cristianvasquez's full-sized avatar
♠️

Cristian Vasquez cristianvasquez

♠️
View GitHub Profile
@cristianvasquez
cristianvasquez / RDF-tree 3dDemo.vue
Created April 18, 2025 09:25
PoC of 3d layers for rdf-tree
<script setup>
import { onMounted } from 'vue'
onMounted(() => {
const rotatable = document.getElementById('rotatable')
let isDragging = false
let previousX = 0
let previousY = 0
let currentRotationX = 0
This file has been truncated, but you can view the full file.
@prefix cccev: <http://data.europa.eu/m8g/> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix epd: <http://data.europa.eu/a4g/resource/> .
@prefix epo: <http://data.europa.eu/a4g/ontology#> .
@prefix locn: <http://www.w3.org/ns/locn#> .
@prefix org: <http://www.w3.org/ns/org#> .
@prefix ql: <http://semweb.mmlab.be/ns/ql#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rml: <http://semweb.mmlab.be/ns/rml#> .
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix : <http://joinup.ec.europa.eu/collection/access-base-registries/solution/abr-specification-registry-registries#> .
@prefix adms: <http://www.w3.org/ns/adms#> .
@prefix cc: <http://creativecommons.org/ns#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix dcat: <http://www.w3.org/ns/dcat#> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix locn: <http://www.w3.org/ns/locn#> .
@prefix org: <http://www.w3.org/ns/org#> .
@cristianvasquez
cristianvasquez / periods-2024-2025.ttl
Last active January 8, 2025 15:59
time instances example
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix time: <http://www.w3.org/2006/time#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <http://schema.org/> .
<http://data.europa.eu/a4g/vocabulary/time/one-year> a time:DurationDescription ;
rdfs:comment "A duration of one year"@en ;
schema:name "1 year"@en ;
time:years "1"^^<http://www.w3.org/2001/XMLSchema#decimal> .
@cristianvasquez
cristianvasquez / get-all.rq
Created January 8, 2025 15:14
SPARQL anything - Notice
PREFIX qb: <http://purl.org/linked-data/cube#>
PREFIX ex: <http://data.europa.eu/exchange-rates/ontology#>
PREFIX dmx-concept: <http://purl.org/linked-data/sdmx/2009/concept#>
PREFIX sdmx-code: <http://purl.org/linked-data/sdmx/2009/code#>
PREFIX sdmx-dimension: <http://purl.org/linked-data/sdmx/2009/dimension#>
PREFIX sdmx-attribute: <http://purl.org/linked-data/sdmx/2009/attribute#>
PREFIX sdmx-measure: <http://purl.org/linked-data/sdmx/2009/measure#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
@cristianvasquez
cristianvasquez / vue.yml
Last active December 18, 2024 11:35
Deploy github Vue.js
name: Deploy Vue site to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
@prefix ex:
<http://example.org/> .
ex:aliceGraph {
ex:Alice ex:name "Alice" ;
ex:knows ex:Bob .
}
ex:bobGraph {
ex:Bob ex:name "Bob" .
@cristianvasquez
cristianvasquez / gist:19634b549b635bd59b9696f0ef34141a
Last active April 15, 2025 11:37
Transforming XML to RDF through RDB

Transforming XML to RDF through RDB

When generating notice/RDF, the ted-rdf-mapping-eforms repository map N source schemas to a single target ontology (v4.0), resulting in N individual mappings. With each update to the ontology, all N mappings must also be updated, adding complexity and cost.

By introducing an intermediate model as a pivot, we can simplify ontology upgrades. The concept is to map the N source schemas to the pivot, and then map the pivot to RDF. This reduces the number of mappings to maintain during Ontology upgrades to one.

One approach for this pivot model is to use an in-memory relational database (RDB), where the XML data is mapped to relational tables. RDF can then be produced from the relational schema using a mapping language such as R2RML.

This method will enhance performance and clarity in the mapping process.

Transform using RML

Get the mappings

First, clone or download this repository

git clone https://github.com/OP-TED/ted-rdf-mapping-eforms.git
from IPython.core.display import display, HTML
from rdflib import Graph
from pyvis.network import Network
import hashlib
def generate_id(value):
"""Generate a unique ID for each RDF term."""
return hashlib.md5(str(value).encode()).hexdigest()
def graph_html(g):