This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # script for testing https://github.com/w3c/rdf-canon/issues/233 | |
| # usage: | |
| # python test_rdf-canon_233.py <N> <comman> <args>* | |
| # where | |
| # - N is the number of permutations+relabeling to test | |
| # - command args is a command reading N-Quads on stdin | |
| # and producing the canonical form on stdout | |
| from collections import defaultdict | |
| import random |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/bash | |
| # dependency: https://github.com/pchampin/sophia-cli | |
| sop parse "$1" --base x-dummy-base: ! canonicalize | |
| # NB: we use a dummy base so that the result does not depend on the location of "$1". | |
| # Indeed, I use this script primarily to re-process RDF files before git diff, | |
| # so the different copies of the *same* files should not be considered to have different bases. | |
| # | |
| # Snippet from by ~/.gitconfig file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # usage: rdfdiff <file1> <file2> [git-diff options...] | |
| # set base URI with the BASE environment variable, if necessary | |
| # requires a "release" build of sophia examples 'parse' and 'canonicalize' | |
| # in a clone of https://github.com/pchampin/sophia_rs | |
| # indicated by SOPHIA_HOME (defaults to ~/dev/sophia_rs) | |
| # | |
| # To produce them, run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @prefix s: <http://schema.org/>. | |
| # simple (unqualified) statement | |
| :dr_strangelove a s:Movie ; | |
| s:actor :peter_sellers. | |
| # RDF-star with "ocurrence" nodes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # | |
| # Command-line JSON-LD processor based on PyLD | |
| # | |
| # Copyright © 2021-2022 Pierre-Antoine Champin <pierre-antoine@w3.org> | |
| import argparse | |
| import json | |
| import sys | |
| from urllib.parse import urljoin, urlsplit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| """ | |
| This script checks different triple stores implementing RDF*, | |
| to see how opaque/transparent are the terms used in embedded triples. | |
| """ | |
| from sys import argv, stderr | |
| import base64 | |
| try: | |
| import requests | |
| except: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. | |
| @prefix math: <http://www.w3.org/2000/10/swap/math#>. | |
| @prefix : <#>. | |
| { (?lst 1) :memberAt ?elt } <= { ?lst rdf:first ?elt. }. | |
| { (?lst ?i) :memberAt ?elt } <= { ?lst rdf:first ?elt. ?i math:equalTo 1. }. | |
| { (?lst ?i) :memberAt ?elt } <= { ?lst rdf:rest ?rest. (?rest ?j) :memberAt ?elt. (?j 1) math:sum ?i. }. | |
| { ((41) 1) :memberAt 41 } => { :TEST :PASS 1 }. | |
| { ((41) 1.0) :memberAt 41 } => { :TEST :PASS 2 }. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //! This is an experiment on how to get rid of lifetime parameters in | |
| //! Sopghia's Graph and Dataset traits. It demonstrates the general idea | |
| //! on a simplified version of Triple and Graph. | |
| //! | |
| //! Graph iterators no longer return Graph::Triple's, | |
| //! they return a safe abstraction around it: GuardedTRiple<'a, Graph::Triple>. | |
| //! | |
| //! Graph::Triple itself can be one of several options: | |
| //! * T (where T implements Triple) | |
| //! * *const T (where T implements Triple) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import namedtuple | |
| from timeit import default_timer | |
| from itertools import repeat | |
| class Classic(object): | |
| def __init__(self, a, b, c): | |
| self.a = a | |
| self.b = b | |
| self.c = c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from rdflib import BNode, URIRef | |
| from rdflib.plugins.stores.sparqlstore import SPARQLUpdateStore, _node_to_sparql, _node_from_result, SPARQL_NS | |
| from uuid import uuid4 | |
| def _virtuoso_compatible_generator(): | |
| return unicode(uuid4().int % 2**61) | |
| # monkey patch BNode to make it virtuoso compatible | |
| BNode.__new__.func_defaults = (None, _virtuoso_compatible_generator, 'b') |
NewerOlder