Skip to content

Instantly share code, notes, and snippets.

@stefanprobst
Last active January 21, 2023 14:14

Revisions

  1. stefanprobst revised this gist Jan 21, 2023. 2 changed files with 1130 additions and 1128 deletions.
    2,257 changes: 1,129 additions & 1,128 deletions frbroo.json
    1,129 additions, 1,128 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
    1 change: 1 addition & 0 deletions generate-frbroo.py
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,7 @@
    g.parse(url, format="xml")

    context = {
    "frbroo": "http://iflastandards.info/ns/fr/frbr/frbroo/",
    "crm": "http://www.cidoc-crm.org/cidoc-crm/",
    "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
  2. stefanprobst created this gist Jan 21, 2023.
    3,341 changes: 3,341 additions & 0 deletions frbroo.json
    3,341 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
    23 changes: 23 additions & 0 deletions generate-frbroo.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    from rdflib import Graph

    # url = "http://iflastandards.info/ns/fr/frbr/frbroo.xml"
    # url = "https://raw.githubusercontent.com/iflastandards/fr/master/xml/ns/fr/frbr/frbroo.xml"
    url = "https://www.cidoc-crm.org/frbroo/sites/default/files/FRBR2.4-draft.rdfs"

    g = Graph()

    g.parse(url, format="xml")

    context = {
    "crm": "http://www.cidoc-crm.org/cidoc-crm/",
    "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
    "owl": "http://www.w3.org/2002/07/owl#",
    "id": "@id",
    "type": "@type"
    }

    s = g.serialize(format="json-ld", context=context)

    with open("frbroo.json", "w") as f:
    f.write(s)