Datenformate
Das ESFC-Glossar ist in 8+ Formaten verfügbar, um verschiedene Anwendungsfälle zu unterstützen - von Web-Anwendungen über Semantic-Web-Integration bis hin zu Datenbankabfragen und typsicherer Programmierung.
Überblick
Alle Formate werden aus einem einzigen LinkML-Schema generiert, was Konsistenz über alle Ausgaben gewährleistet und gleichzeitig jedes Format für seinen spezifischen Anwendungsfall optimiert.
Verfügbare Formate:
- SQLite-Datenbank (133 MB)
- JSON (189 MB)
- LinkML YAML (157 MB)
- JSON-LD (Semantic Web)
- TypeScript-Typen
- RDF/OWL-Ontologien
- SQL DDL-Schemata
- CSV/Excel
Primärformate
SQLite-Datenbank
Datei: glossary.db
Größe: 133 MB
Anwendungsfall: Abfragen, Beziehungen, Anwendungsintegration
Die SQLite-Datenbank bietet optimierte Speicherung und schnelle Abfragen für das vollständige Glossar.
Datenbankschema
-- Haupttabelle für Begriffe
CREATE TABLE terms (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
description TEXT,
source TEXT NOT NULL,
category TEXT,
properties JSON,
external_mappings JSON,
parent_terms JSON,
metadata JSON,
status TEXT DEFAULT 'active',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Indizes für Performance
CREATE INDEX idx_source ON terms(source);
CREATE INDEX idx_category ON terms(category);
CREATE INDEX idx_name ON terms(name);
CREATE INDEX idx_status ON terms(status);
-- Volltextsuche
CREATE VIRTUAL TABLE terms_fts USING fts5(
id, name, description, category,
content=terms
);
-- Beziehungstabelle
CREATE TABLE relationships (
id INTEGER PRIMARY KEY AUTOINCREMENT,
source_term_id TEXT NOT NULL,
target_term_id TEXT NOT NULL,
relationship_type TEXT NOT NULL,
confidence REAL,
method TEXT,
FOREIGN KEY (source_term_id) REFERENCES terms(id),
FOREIGN KEY (target_term_id) REFERENCES terms(id)
);
CREATE INDEX idx_relationships_source ON relationships(source_term_id);
CREATE INDEX idx_relationships_target ON relationships(target_term_id);
Abfragebeispiele
Grundlegende Abfragen:
-- Begriffe nach Quelle zählen
SELECT source, COUNT(*) as term_count
FROM terms
GROUP BY source
ORDER BY term_count DESC;
-- Alle weizenbezogenen Begriffe finden
SELECT id, name, source, category
FROM terms
WHERE name LIKE '%wheat%'
ORDER BY source, name;
-- Volltextsuche
SELECT t.id, t.name, t.source, t.category
FROM terms_fts fts
JOIN terms t ON fts.id = t.id
WHERE terms_fts MATCH 'carbon emission'
LIMIT 20;
Erweiterte Abfragen:
-- Begriffe mit Beziehungen finden
SELECT
t1.id as source_id,
t1.name as source_name,
r.relationship_type,
t2.name as target_name,
t2.source as target_source,
r.confidence
FROM terms t1
JOIN relationships r ON t1.id = r.source_term_id
JOIN terms t2 ON t2.id = r.target_term_id
WHERE t1.source = 'foodex2'
AND t2.source = 'hestia'
ORDER BY r.confidence DESC
LIMIT 10;
-- Hierarchische Abfragen
WITH RECURSIVE hierarchy AS (
SELECT id, name, parent_terms, 1 as level
FROM terms
WHERE id = 'foodex2-A0101'
UNION ALL
SELECT t.id, t.name, t.parent_terms, h.level + 1
FROM terms t
JOIN hierarchy h
WHERE json_extract(t.parent_terms, '$[0]') = h.id
)
SELECT * FROM hierarchy;
Integrationsbeispiele
Python:
import sqlite3
# Mit Datenbank verbinden
conn = sqlite3.connect('glossary.db')
cursor = conn.cursor()
# Begriffe abfragen
cursor.execute('''
SELECT id, name, source, category
FROM terms
WHERE source = ?
LIMIT 10
''', ('hestia',))
for row in cursor.fetchall():
print(f"{row[0]}: {row[1]} ({row[2]})")
conn.close()
Node.js:
import Database from 'better-sqlite3'
const db = new Database('glossary.db')
// Vorbereitete Anweisung
const stmt = db.prepare(`
SELECT id, name, source, category
FROM terms
WHERE source = ? AND category LIKE ?
`)
const results = stmt.all('hestia', '%Emission%')
console.log(`${results.length} Emissionsbegriffe gefunden`)
JSON-Format
Datei: glossary.json
Größe: 189 MB
Anwendungsfall: Web-Anwendungen, JavaScript/TypeScript-Integration
Vollständige Glossardaten im JSON-Format mit allen Begriffsdetails und Metadaten.
Struktur
{
"metadata": {
"version": "0.1.2",
"build": 6,
"lastUpdated": "2025-12-08T02:54:36.996Z",
"totalTerms": 168626,
"sources": {
"foodex2": 31601,
"hestia": 36044,
"ecoinvent": 33784,
"agrovoc": 41447,
"langual": 12836,
"cpc": 4583,
"sentier": 7731,
"unece": 406,
"gs1": 154,
"eaternity": 40
}
},
"terms": [
{
"@type": "Term",
"id": "foodex2-A010101",
"name": "Common wheat",
"description": "Triticum aestivum, bread wheat",
"source": "foodex2",
"category": "Grains",
"properties": {
"hierarchyCode": "A010101",
"scientificName": "Triticum aestivum",
"level": 4
},
"external_mappings": [
{
"externalId": "hestia-crop-wheat",
"externalSource": "hestia",
"mappingType": "related"
}
],
"parent_terms": ["foodex2-A0101"],
"metadata": {
"searchable": true,
"verified": true
},
"status": "active"
}
]
}
Verwendungsbeispiele
JavaScript/TypeScript:
// Glossar laden
const glossary = await fetch('/glossary.json')
.then(r => r.json())
// Nach Quelle filtern
const hestiaTerms = glossary.terms.filter(t =>
t.source === 'hestia'
)
// Nach Name suchen
const searchResults = glossary.terms.filter(t =>
t.name.toLowerCase().includes('wheat')
)
// Nach Kategorie gruppieren
const byCategory = glossary.terms.reduce((acc, term) => {
const cat = term.category || 'Uncategorized'
if (!acc[cat]) acc[cat] = []
acc[cat].push(term)
return acc
}, {})
Python:
import json
with open('glossary.json') as f:
glossary = json.load(f)
# Auf Metadaten zugreifen
print(f"Version: {glossary['metadata']['version']}")
print(f"Gesamtanzahl Begriffe: {glossary['metadata']['totalTerms']}")
# Begriffe filtern
hestia_terms = [
t for t in glossary['terms']
if t['source'] == 'hestia'
]
# Suchen
wheat_terms = [
t for t in glossary['terms']
if 'wheat' in t['name'].lower()
]
LinkML YAML
Datei: glossary.yaml
Größe: 157 MB
Anwendungsfall: Semantic Web, Forschung, Datenvalidierung
Natives LinkML-Format mit vollständigen semantischen Annotationen und Beziehungen.
Struktur
terms:
- '@type': Term
id: foodex2-A010101
name: Common wheat
description: Triticum aestivum, bread wheat
source: foodex2
category: Grains
properties:
hierarchyCode: A010101
scientificName: Triticum aestivum
level: 4
external_mappings:
- externalId: hestia-crop-wheat
externalSource: hestia
mappingType: related
parent_terms:
- foodex2-A0101
metadata:
searchable: true
verified: true
status: active
Verwendung mit LinkML
Python mit LinkML Runtime:
from linkml_runtime.loaders import yaml_loader
from glossary_model import Glossary, Term
# Glossar laden
glossary = yaml_loader.load('glossary.yaml', target_class=Glossary)
# Auf Begriffe zugreifen
print(f"{len(glossary.terms)} Begriffe geladen")
# Nach Quelle filtern
hestia_terms = [t for t in glossary.terms if t.source == 'hestia']
# Gegen Schema validieren
from linkml_runtime.utils.schemaview import SchemaView
schema = SchemaView('schema/glossary.linkml.yaml')
for term in glossary.terms[:10]:
schema.validate_object(term, target_class='Term')
JSON-LD (Semantic Web)
Datei: glossary.jsonld
Größe: ~200 MB
Anwendungsfall: Semantic Web, RDF-Integration, Linked Data
JSON-LD-Format mit Semantic-Web-Kontext für RDF/SPARQL-Integration.
Struktur
{
"@context": {
"@vocab": "http://esfc-glossary.org/vocab/",
"skos": "http://www.w3.org/2004/02/skos/core#",
"dc": "http://purl.org/dc/terms/",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"Term": "skos:Concept",
"name": "skos:prefLabel",
"description": "skos:definition",
"source": "dc:source",
"category": "skos:inScheme",
"parent_terms": "skos:broader",
"external_mappings": {
"@id": "skos:relatedMatch",
"@container": "@set"
}
},
"@graph": [
{
"@type": "Term",
"@id": "foodex2:A010101",
"name": "Common wheat",
"description": "Triticum aestivum, bread wheat",
"source": "foodex2",
"category": "Grains",
"parent_terms": ["foodex2:A0101"],
"external_mappings": [
{
"@id": "hestia:crop-wheat",
"mappingType": "related"
}
]
}
]
}
SPARQL-Abfragen
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX dc: <http://purl.org/dc/terms/>
# Alle Weizenbegriffe finden
SELECT ?term ?label ?source WHERE {
?term skos:prefLabel ?label ;
dc:source ?source .
FILTER(CONTAINS(LCASE(?label), "wheat"))
}
LIMIT 10
# Verknüpfte Begriffe finden
SELECT ?source ?target ?type WHERE {
?source skos:relatedMatch ?target .
?source dc:source "foodex2" .
?target dc:source "hestia" .
}
Generierte Formate
TypeScript-Typen
Datei: glossary.types.ts
Größe: ~500 KB
Anwendungsfall: Typsichere TypeScript/JavaScript-Integration
Generierte TypeScript-Typdefinitionen für das Glossar-Schema.
Generierte Typen
/**
* Haupt-Glossar-Schnittstelle
*/
export interface Glossary {
metadata: GlossaryMetadata
terms: Term[]
}
/**
* Metadaten über das Glossar
*/
export interface GlossaryMetadata {
version: string
build: number
lastUpdated: string
totalTerms: number
sources: Record<string, number>
}
/**
* Einzelner Glossarbegriff
*/
export interface Term {
'@type': 'Term'
id: string
name: string
description?: string
source: GlossarySource
category?: string
properties?: Record<string, any>
external_mappings?: ExternalMapping[]
parent_terms?: string[]
metadata?: Record<string, any>
status: TermStatus
}
/**
* Glossarquellen
*/
export type GlossarySource =
| 'foodex2'
| 'hestia'
| 'ecoinvent'
| 'agrovoc'
| 'langual'
| 'cpc'
| 'sentier'
| 'unece'
| 'gs1'
| 'eaternity'
/**
* Externe Zuordnung zu anderen Vokabularen
*/
export interface ExternalMapping {
externalId: string
externalSource: string
mappingType: 'exact' | 'related' | 'broader' | 'narrower'
confidence?: number
}
/**
* Begriffsstatus
*/
export type TermStatus = 'active' | 'deprecated' | 'obsolete'
Verwendung
import { Glossary, Term, GlossarySource } from './glossary.types'
async function loadGlossary(): Promise<Glossary> {
const response = await fetch('/glossary.json')
return response.json()
}
function filterBySource(
terms: Term[],
source: GlossarySource
): Term[] {
return terms.filter(t => t.source === source)
}
// Typsichere Verwendung
const glossary = await loadGlossary()
const hestiaTerms = filterBySource(glossary.terms, 'hestia')
// TypeScript gewährleistet Typsicherheit
console.log(`${hestiaTerms.length} Hestia-Begriffe gefunden`)
SQL DDL-Schema
Datei: glossary.sql
Größe: ~50 KB
Anwendungsfall: Datenbank-Schema-Erstellung, PostgreSQL/MySQL-Einrichtung
SQL-Schema-Definition zur Erstellung von Datenbanktabellen.
Generiertes Schema
-- Begriffstabelle
CREATE TABLE terms (
id VARCHAR(255) PRIMARY KEY,
name TEXT NOT NULL,
description TEXT,
source VARCHAR(50) NOT NULL,
category VARCHAR(255),
properties JSONB,
external_mappings JSONB,
parent_terms JSONB,
metadata JSONB,
status VARCHAR(50) DEFAULT 'active',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Indizes
CREATE INDEX idx_terms_source ON terms(source);
CREATE INDEX idx_terms_category ON terms(category);
CREATE INDEX idx_terms_name ON terms USING gin(to_tsvector('english', name));
CREATE INDEX idx_terms_properties ON terms USING gin(properties);
-- Volltextsuche (PostgreSQL)
CREATE INDEX idx_terms_fts ON terms
USING gin(to_tsvector('english', coalesce(name, '') || ' ' || coalesce(description, '')));
-- Materialisierte Ansicht für Quellenstatistiken
CREATE MATERIALIZED VIEW source_statistics AS
SELECT
source,
COUNT(*) as term_count,
COUNT(DISTINCT category) as category_count,
MIN(created_at) as first_added,
MAX(updated_at) as last_updated
FROM terms
GROUP BY source;
RDF/OWL-Ontologie
Datei: glossary.owl
Größe: ~250 MB
Anwendungsfall: Semantic-Web-Anwendungen, Ontologie-Reasoning
OWL-Ontologie für Semantic-Web-Reasoning und Inferenz.
Ontologie-Struktur
<?xml version="1.0"?>
<rdf:RDF xmlns="http://esfc-glossary.org/ontology#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:skos="http://www.w3.org/2004/02/skos/core#">
<owl:Ontology rdf:about="http://esfc-glossary.org/ontology">
<rdfs:label>ESFC-Glossar-Ontologie</rdfs:label>
<rdfs:comment>
Einheitliche Lebensmittel- und Ökobilanz-Glossar-Ontologie
</rdfs:comment>
</owl:Ontology>
<!-- Klassen -->
<owl:Class rdf:about="http://esfc-glossary.org/ontology#Term">
<rdfs:label>Term</rdfs:label>
<rdfs:subClassOf rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>
</owl:Class>
<!-- Eigenschaften -->
<owl:DatatypeProperty rdf:about="http://esfc-glossary.org/ontology#source">
<rdfs:domain rdf:resource="http://esfc-glossary.org/ontology#Term"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</owl:DatatypeProperty>
<!-- Individuen (Begriffe) -->
<owl:NamedIndividual rdf:about="http://esfc-glossary.org/terms/foodex2-A010101">
<rdf:type rdf:resource="http://esfc-glossary.org/ontology#Term"/>
<skos:prefLabel>Common wheat</skos:prefLabel>
<skos:definition>Triticum aestivum, bread wheat</skos:definition>
</owl:NamedIndividual>
</rdf:RDF>
Exportformate
CSV-Export
Generieren Sie CSV-Dateien für spezifische Begriffsuntergruppen.
Exportstruktur
id,name,description,source,category,properties,status
foodex2-A010101,"Common wheat","Triticum aestivum",foodex2,Grains,"{""hierarchyCode"":""A010101""}",active
hestia-crop-wheat,"Wheat crop","Agricultural wheat production",hestia,"Inputs & Products","{}",active
Export-Skripte
# Alle Begriffe nach CSV exportieren
npm run export:csv
# Spezifische Quelle exportieren
npm run export:csv -- --source hestia
# Mit Filtern exportieren
npm run export:csv -- --source foodex2 --category Grains
Excel-Export
Mehrseitige Excel-Arbeitsmappe mit organisierten Daten.
Arbeitsmappen-Struktur
Blatt 1: Übersicht
- Metadaten und Statistiken
- Quellenzusammenfassung
- Kategorieaufschlüsselung
Blatt 2: Alle Begriffe
- Vollständige Begriffsliste
- Filterbare Spalten
- Farbcodiert nach Quelle
Blatt 3: FoodEx2
- FoodEx2-Begriffe mit Hierarchie
- Facetteninformationen
Blatt 4: Hestia
- Hestia-Ökobilanz-Begriffe
- Kategorieorganisation
Blatt 5: Beziehungen
- Quellenübergreifende Zuordnungen
- Konfidenzwerte
- Zuordnungsmethoden
Generierung
# Excel-Arbeitsmappe generieren
npm run export:excel
# Benutzerdefinierter Export
node scripts/export-excel.js \
--output glossary.xlsx \
--include-relationships
Download-Speicherorte
Alle Formate stehen zum Download bereit:
https://esfc-glossary-ec2bc9.gitlab.io/downloads/
├── glossary.db # SQLite-Datenbank (133 MB)
├── glossary.json # JSON-Format (189 MB)
├── glossary.yaml # LinkML YAML (157 MB)
├── glossary.jsonld # JSON-LD (200 MB)
├── glossary.types.ts # TypeScript-Typen (500 KB)
├── glossary.owl # OWL-Ontologie (250 MB)
├── glossary.sql # SQL DDL (50 KB)
├── glossary.csv # CSV-Export (variabel)
└── glossary.xlsx # Excel-Arbeitsmappe (variabel)
Formatauswahl-Leitfaden
Wählen Sie das richtige Format für Ihren Anwendungsfall:
| Anwendungsfall | Empfohlenes Format | Begründung |
|---|---|---|
| Web-Anwendung | JSON oder SQLite | Schnelles Laden, einfache Integration |
| Typsichere Entwicklung | TypeScript-Typen + JSON | Typsicherheit und Autovervollständigung |
| Datenbankanwendung | SQLite oder SQL DDL | Optimierte Abfragen |
| Semantic Web | JSON-LD oder RDF/OWL | RDF/SPARQL-Kompatibilität |
| Forschung | LinkML YAML | Vollständige semantische Annotationen |
| Datenanalyse | CSV oder Excel | Tabellenkalkulationswerkzeuge |
| Python-Integration | SQLite oder LinkML YAML | Native Unterstützung |
| Node.js-Integration | JSON oder SQLite | Einfaches Parsen |
Generierungs-Pipeline
Alle Formate werden aus dem LinkML-Schema generiert:
LinkML-Schema (glossary.linkml.yaml)
↓
Daten-Parsing & Validierung
↓
LinkML YAML (natives Format)
↓
Mehrformat-Generierung
├── JSON (linkml-convert)
├── JSON-LD (linkml-convert)
├── TypeScript (linkml-generate-typescript)
├── OWL (linkml-convert)
├── SQL DDL (linkml-generate-sql)
└── SQLite (benutzerdefiniertes Skript)
↓
Optimierung & Komprimierung
↓
Bereitstellung im CDN
Verwandte Dokumentation
- Datenquellen - Übersicht aller 10 Quellen
- Semantische Zuordnung - Quellenübergreifende Beziehungen
- Glossar-Übersicht - Hauptdokumentation
- FoodEx2-Referenz - Lebensmittelklassifizierung
- Hestia-Referenz - Ökobilanz-Daten