diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index d107e62..58a8d7e 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -28,13 +28,13 @@ jobs: pymdown-extensions - name: Install library - run: pip install -e ./csvw-safe-library + run: pip install -e ./csvw-eo-library - name: Sync images run: | mkdir -p docs/images cp -r images/* docs/images/ - cp -r csvw-safe-library/images/* docs/images/ + cp -r csvw-eo-library/images/* docs/images/ - name: Build docs run: mkdocs build @@ -46,5 +46,5 @@ jobs: with: source-directory: site/ destination-github-username: dscc-admin-ch - destination-repository-name: csvw-safe-docs + destination-repository-name: csvw-eo-docs target-branch: main \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3366032..f958479 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,7 +10,7 @@ jobs: defaults: run: - working-directory: csvw-safe-library + working-directory: csvw-eo-library steps: - name: Checkout repo diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 29f7cdd..a3b6386 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,12 +27,12 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - cd csvw-safe-library + cd csvw-eo-library pip install -e .[dev] - name: Run tests with coverage run: | - cd csvw-safe-library + cd csvw-eo-library coverage run -m pytest . -vv coverage xml @@ -40,6 +40,6 @@ jobs: uses: py-cov-action/python-coverage-comment-action@v3 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERAGE_PATH: csvw-safe-library/ + COVERAGE_PATH: csvw-eo-library/ MINIMUM_GREEN: 90 MINIMUM_ORANGE: 80 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4369b40..4806c1f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ __pycache__/* *pyd images/*ipynb* */build/* -*/csvw_safe.egg-info/* +*/csvw_eo.egg-info/* *.ipynb_checkpoints/* .ipynb_checkpoints/ *coverage diff --git a/README.md b/README.md index ddbf887..2b645c8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# CSVW-SAFE +# CSVW-EO -CSVW-SAFE extends the W3C CSV on the Web (CSVW) standard with +CSVW-EO extends the W3C CSV on the Web (CSVW) standard with privacy-safe metadata for: - Differential Privacy contribution modeling @@ -10,16 +10,16 @@ privacy-safe metadata for: - Validation workflows Documentation: -https://dscc-admin-ch.github.io/csvw-safe-docs/ +https://dscc-admin-ch.github.io/csvw-eo-docs/ --- -## Why CSVW-SAFE? +## Why CSVW-EO? Many datasets cannot be shared directly due to privacy or governance constraints. -CSVW-SAFE allows publishing safe assumptions about datasets without +CSVW-EO allows publishing safe assumptions about datasets without sharing the underlying sensitive data. Examples include: @@ -30,7 +30,7 @@ Examples include: - contribution bounds for DP - logical dependencies -![Overview](images/csvw-safe_structure.png) +![Overview](images/csvw-eo_structure.png) --- @@ -38,24 +38,24 @@ Examples include: | Component | Description | |---|---| -| `csvw-safe-library/` | Python library | +| `csvw-eo-library/` | Python library | | `docs/` | MkDocs documentation | -| `csvw-safe-vocab.ttl` | RDF vocabulary | -| `csvw-safe-constraints.ttl` | SHACL validation rules | +| `csvw-eo-vocab.ttl` | RDF vocabulary | +| `csvw-eo-constraints.ttl` | SHACL validation rules | --- ## Installation ```bash -pip install csvw-safe +pip install csvw-eo ``` ## Quick Example ```bash -from csvw_safe.make_metadata_from_data import make_metadata_from_data -from csvw_safe.make_dummy_from_metadata import make_dummy_from_metadata +from csvw_eo.make_metadata_from_data import make_metadata_from_data +from csvw_eo.make_dummy_from_metadata import make_dummy_from_metadata metadata = make_metadata_from_data( df, @@ -68,6 +68,6 @@ dummy_df = make_dummy_from_metadata(metadata) | Section | Link | | -------------- | ------------------------------------------------------------------------------------------------------------------------ | -| Vocabulary | [https://dscc-admin-ch.github.io/csvw-safe-docs/vocabulary/overview/](https://dscc-admin-ch.github.io/csvw-safe-docs/vocabulary/overview/) | -| Python Library | [https://dscc-admin-ch.github.io/csvw-safe-docs/library/overview/](https://dscc-admin-ch.github.io/csvw-safe-docs/library/overview/) | -| API Reference | [https://dscc-admin-ch.github.io/csvw-safe-docs/api/](https://dscc-admin-ch.github.io/csvw-safe-docs/api/) | +| Vocabulary | [https://dscc-admin-ch.github.io/csvw-eo-docs/vocabulary/overview/](https://dscc-admin-ch.github.io/csvw-eo-docs/vocabulary/overview/) | +| Python Library | [https://dscc-admin-ch.github.io/csvw-eo-docs/library/overview/](https://dscc-admin-ch.github.io/csvw-eo-docs/library/overview/) | +| API Reference | [https://dscc-admin-ch.github.io/csvw-eo-docs/api/](https://dscc-admin-ch.github.io/csvw-eo-docs/api/) | diff --git a/csvw-safe-constraints.md b/csvw-eo-constraints.md similarity index 88% rename from csvw-safe-constraints.md rename to csvw-eo-constraints.md index 1ab5f3a..774c4ac 100644 --- a/csvw-safe-constraints.md +++ b/csvw-eo-constraints.md @@ -1,6 +1,6 @@ -# CSVW-SAFE Constraints +# CSVW-EO Constraints -CSVW-SAFE enforces constraints to ensure: +CSVW-EO enforces constraints to ensure: - Structural consistency of the admissible dataset universe - Sound worst-case sensitivity computation @@ -15,9 +15,9 @@ Applied to `csvw:Table`: The following properties are required if the dataset is intended for DP calibration: | Property | Constraint | | ----------------------------------- | ----------------------------------------- | -| `csvw-safe:public.privacyUnit` | MUST reference an existing column | -| `csvw-safe:bounds.maxLength` | MUST be declared | -| `csvw-safe:bounds.maxContributions` | MUST be declared and ≤ `bounds.maxLength` | +| `csvw-eo:public.privacyUnit` | MUST reference an existing column | +| `csvw-eo:bounds.maxLength` | MUST be declared | +| `csvw-eo:bounds.maxContributions` | MUST be declared and ≤ `bounds.maxLength` | If there is no groupy, then these fields are compulsory at the table level. If there is a groupby, then these fields are compulsory at the partition level. @@ -27,8 +27,8 @@ If there is a groupby, then these fields are compulsory at the partition level. | Property | Constraint | | ----------------------------------- | ------------------------------------------------------------------------ | -| `csvw-safe:public.length` | If declared, MUST be ≤ `bounds.maxLength` and invariant across neighbors | -| `csvw-safe:bounds.maxNumPartitions` | If declared at table level, MUST be ≥ 1 | +| `csvw-eo:public.length` | If declared, MUST be ≤ `bounds.maxLength` and invariant across neighbors | +| `csvw-eo:bounds.maxNumPartitions` | If declared at table level, MUST be ≥ 1 | ### 4.1.3 Global consistency rules @@ -64,7 +64,7 @@ If column-level bounds are omitted, table-level bounds apply. ## 4.3 Multi-Column GroupingKey Constraints -Applied to `csvw-safe:GroupingKey`. +Applied to `csvw-eo:GroupingKey`. ### 4.3.1 Structural consistency @@ -98,7 +98,7 @@ For a grouping key G composed of columns $C_1, C_2, ..., C_n$: ## 4.4 Partition-Level Constraints -Applied to `csvw-safe:Partition`. +Applied to `csvw-eo:Partition`. A Partition represents exactly one output coordinate. @@ -128,7 +128,7 @@ Implicit rule: ## 4.5 Contribution Object Constraints (Multiple Privacy Units) -Applied to `csvw-safe:Contribution`. +Applied to `csvw-eo:Contribution`. ### 4.5.1 Structural rules | Rule | Enforcement | @@ -187,5 +187,5 @@ If any required property is missing: DP bounds are undefined. ## 4.9 SHACL Enforcement -Some constraints are enforcet in [`csvw-safe-constraints.ttl`](https://github.com/dscc-admin-ch/csvw-safe/blob/main/csvw-safe-library/csvw-safe-constraints.ttl). -Other more detailed constraints are in [`validate_metadata.py`](https://github.com/dscc-admin-ch/csvw-safe/blob/main/csvw-safe-library/csvw-safe/validate_metadata.py) and [`validate_metadata_shacl.py`](https://github.com/dscc-admin-ch/csvw-safe/blob/main/csvw-safe-library/csvw-safe/validate_metadata_shacl.py) can run the shacl constraints. +Some constraints are enforcet in [`csvw-eo-constraints.ttl`](https://github.com/dscc-admin-ch/csvw-eo/blob/main/csvw-eo-library/csvw-eo-constraints.ttl). +Other more detailed constraints are in [`validate_metadata.py`](https://github.com/dscc-admin-ch/csvw-eo/blob/main/csvw-eo-library/csvw-eo/validate_metadata.py) and [`validate_metadata_shacl.py`](https://github.com/dscc-admin-ch/csvw-eo/blob/main/csvw-eo-library/csvw-eo/validate_metadata_shacl.py) can run the shacl constraints. diff --git a/csvw-safe-constraints.ttl b/csvw-eo-constraints.ttl similarity index 98% rename from csvw-safe-constraints.ttl rename to csvw-eo-constraints.ttl index 02a9567..9ad87d7 100644 --- a/csvw-safe-constraints.ttl +++ b/csvw-eo-constraints.ttl @@ -1,7 +1,7 @@ @prefix sh: . @prefix xsd: . @prefix csvw: . -@prefix cs: . +@prefix cs: . ############################################ # Table diff --git a/csvw-safe-context.jsonld b/csvw-eo-context.jsonld similarity index 54% rename from csvw-safe-context.jsonld rename to csvw-eo-context.jsonld index 1b3cd09..d1a95ce 100644 --- a/csvw-safe-context.jsonld +++ b/csvw-eo-context.jsonld @@ -2,7 +2,7 @@ "@context": { "csvw": "http://www.w3.org/ns/csvw#", - "csvw-safe": "https://w3id.org/csvw-safe#", + "csvw-eo": "https://w3id.org/csvw-eo#", "xsd": "http://www.w3.org/2001/XMLSchema#", "@version": 1.1, @@ -10,57 +10,57 @@ "Table": "csvw:Table", "Column": "csvw:Column", - "GroupingKey": "csvw-safe:GroupingKey", - "Partition": "csvw-safe:Partition", - "Predicate": "csvw-safe:Predicate", - "Contribution": "csvw-safe:Contribution", + "GroupingKey": "csvw-eo:GroupingKey", + "Partition": "csvw-eo:Partition", + "Predicate": "csvw-eo:Predicate", + "Contribution": "csvw-eo:Contribution", "columns": { - "@id": "csvw-safe:columns", + "@id": "csvw-eo:columns", "@type": "@id", "@container": "@set" }, "predicate": { - "@id": "csvw-safe:predicate", + "@id": "csvw-eo:predicate", "@type": "@id" }, "components": { - "@id": "csvw-safe:components", + "@id": "csvw-eo:components", "@type": "@id", "@container": "@index" }, - "partitionValue": "csvw-safe:partitionValue", + "partitionValue": "csvw-eo:partitionValue", "lowerBound": { - "@id": "csvw-safe:lowerBound", + "@id": "csvw-eo:lowerBound", "@type": "xsd:decimal" }, "upperBound": { - "@id": "csvw-safe:upperBound", + "@id": "csvw-eo:upperBound", "@type": "xsd:decimal" }, - "privacyModel": "csvw-safe:privacyModel", + "privacyModel": "csvw-eo:privacyModel", "public": { "@context": { "privacyUnit": { - "@id": "csvw-safe:public.privacyUnit", + "@id": "csvw-eo:public.privacyUnit", "@type": "@id" }, "length": { - "@id": "csvw-safe:public.length", + "@id": "csvw-eo:public.length", "@type": "xsd:integer" }, "partitions": { - "@id": "csvw-safe:public.partitions", + "@id": "csvw-eo:public.partitions", "@type": "@id", "@container": "@set" }, "exhaustivePartitions": { - "@id": "csvw-safe:public.exhaustivePartitions", + "@id": "csvw-eo:public.exhaustivePartitions", "@type": "xsd:boolean" } } @@ -69,41 +69,41 @@ "bounds": { "@context": { "maxContributions": { - "@id": "csvw-safe:bounds.maxContributions", + "@id": "csvw-eo:bounds.maxContributions", "@type": "xsd:integer" }, "maxGroupsPerUnit": { - "@id": "csvw-safe:bounds.maxGroupsPerUnit", + "@id": "csvw-eo:bounds.maxGroupsPerUnit", "@type": "xsd:integer" }, "maxLength": { - "@id": "csvw-safe:bounds.maxLength", + "@id": "csvw-eo:bounds.maxLength", "@type": "xsd:integer" }, "maxNumPartitions": { - "@id": "csvw-safe:bounds.maxNumPartitions", + "@id": "csvw-eo:bounds.maxNumPartitions", "@type": "xsd:integer" } } }, "contribution": { - "@id": "csvw-safe:contribution", + "@id": "csvw-eo:contribution", "@type": "@id" }, "contrib": { "@context": { "privacyUnit": { - "@id": "csvw-safe:contribution.privacyUnit", + "@id": "csvw-eo:contribution.privacyUnit", "@type": "@id" }, "maxContributions": { - "@id": "csvw-safe:contribution.maxContributions", + "@id": "csvw-eo:contribution.maxContributions", "@type": "xsd:integer" }, "maxGroupsPerUnit": { - "@id": "csvw-safe:contribution.maxGroupsPerUnit", + "@id": "csvw-eo:contribution.maxGroupsPerUnit", "@type": "xsd:integer" } } @@ -112,14 +112,14 @@ "synth": { "@context": { "nullableProportion": { - "@id": "csvw-safe:synth.nullableProportion", + "@id": "csvw-eo:synth.nullableProportion", "@type": "xsd:decimal" }, "dependency": { - "@id": "csvw-safe:synth.dependency", + "@id": "csvw-eo:synth.dependency", "@type": "@id" }, - "dependencyType": "csvw-safe:synth.dependencyType" + "dependencyType": "csvw-eo:synth.dependencyType" } } } diff --git a/csvw-safe-library/LICENSE b/csvw-eo-library/LICENSE similarity index 100% rename from csvw-safe-library/LICENSE rename to csvw-eo-library/LICENSE diff --git a/csvw-safe-library/README.md b/csvw-eo-library/README.md similarity index 82% rename from csvw-safe-library/README.md rename to csvw-eo-library/README.md index b8505d9..b4f6d4c 100644 --- a/csvw-safe-library/README.md +++ b/csvw-eo-library/README.md @@ -1,15 +1,15 @@ -# CSVW-SAFE Utility Library +# CSVW-EO Utility Library -![GitHub License](https://img.shields.io/github/license/dscc-admin-ch/csvw-safe) -![PyPI - Python Version](https://img.shields.io/pypi/pyversions/csvw-safe) -[![Documentation](https://img.shields.io/badge/docs-Read%20the%20Docs-blue)](https://dscc-admin-ch.github.io/csvw-safe-docs/index.html) -[![Coverage](https://raw.githubusercontent.com/dscc-admin-ch/csvw-safe/python-coverage-comment-action-data/badge.svg)](https://htmlpreview.github.io/?https://github.com/dscc-admin-ch/csvw-safe/blob/python-coverage-comment-action-data/htmlcov/index.html) -[![CodeQL](https://github.com/dscc-admin-ch/csvw-safe/actions/workflows/codeql.yml/badge.svg)](https://github.com/dscc-admin-ch/csvw-safe/actions/workflows/codeql.yml) +![GitHub License](https://img.shields.io/github/license/dscc-admin-ch/csvw-eo) +![PyPI - Python Version](https://img.shields.io/pypi/pyversions/csvw-eo) +[![Documentation](https://img.shields.io/badge/docs-Read%20the%20Docs-blue)](https://dscc-admin-ch.github.io/csvw-eo-docs/index.html) +[![Coverage](https://raw.githubusercontent.com/dscc-admin-ch/csvw-eo/python-coverage-comment-action-data/badge.svg)](https://htmlpreview.github.io/?https://github.com/dscc-admin-ch/csvw-eo/blob/python-coverage-comment-action-data/htmlcov/index.html) +[![CodeQL](https://github.com/dscc-admin-ch/csvw-eo/actions/workflows/codeql.yml/badge.svg)](https://github.com/dscc-admin-ch/csvw-eo/actions/workflows/codeql.yml) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) -See structured and more friendly documentation [here](https://dscc-admin-ch.github.io/csvw-safe-docs/library/overview/). +See structured and more friendly documentation [here](https://dscc-admin-ch.github.io/csvw-eo-docs/library/overview/). -This library provides Python utilities for generating, validating, and testing CSVW-SAFE metadata and associated dummy datasets for differential privacy (DP) development and safe data modeling workflows. +This library provides Python utilities for generating, validating, and testing CSVW-EO metadata and associated dummy datasets for differential privacy (DP) development and safe data modeling workflows. It includes five main scripts: @@ -21,7 +21,7 @@ It includes five main scripts: ![Overview](images/csvwsafe_workflow_1.png) -In addition, two other scripts are available for conversion of csvw-safe metadata to smartnoise sql and opendp libraries: +In addition, two other scripts are available for conversion of csvw-eo metadata to smartnoise sql and opendp libraries: 6. `csvw_to_smartnoise_sql.py` converts the metadata to the format expected in smartnoise-sql 7. `assert_same_structure.py` prepares a context object for opendp with margin and information extracted from csvw-metadata format. @@ -31,7 +31,7 @@ In addition, two other scripts are available for conversion of csvw-safe metadat - These scripts assist safe data modeling workflows; they DO NOT replace governance decisions on what is public information or not. - IMPORTANT: Automatically generated metadata may contain sensitive information — MANUAL REVIEW IS ALWAYS REQUIRED before further steps. -For a description of [CSVW-SAFE metadata, see here](https://github.com/dscc-admin-ch/csvw-safe). +For a description of [CSVW-EO metadata, see here](https://github.com/dscc-admin-ch/csvw-eo). --- @@ -40,26 +40,26 @@ For a description of [CSVW-SAFE metadata, see here](https://github.com/dscc-admi Install Python 3.11+ and ```bash -pip install csvw-safe +pip install csvw-eo ``` or for development: ``` -git clone https://github.com/dscc-admin-ch/csvw-safe-library.git -cd csvw-safe-library +git clone https://github.com/dscc-admin-ch/csvw-eo-library.git +cd csvw-eo-library pip install -e .[dev] ``` For testing: ``` -cd csvw-safe-library +cd csvw-eo-library pip install -e .[dev] -pytest --cov=csvw_safe --cov-report=term-missing tests/ +pytest --cov=csvw_eo --cov-report=term-missing tests/ ``` ## Learn via example -To get to know the library with examples, see the [notebook on the extended penguin dataset](https://github.com/dscc-admin-ch/csvw-safe/blob/main/csvw-safe-library/examples/Use-Library.ipynb) and the associated outputs in [metadata example folder](https://github.com/dscc-admin-ch/csvw-safe/tree/main/csvw-safe-library/examples/metadata). +To get to know the library with examples, see the [notebook on the extended penguin dataset](https://github.com/dscc-admin-ch/csvw-eo/blob/main/csvw-eo-library/examples/Use-Library.ipynb) and the associated outputs in [metadata example folder](https://github.com/dscc-admin-ch/csvw-eo/tree/main/csvw-eo-library/examples/metadata). ## Scripts Overview @@ -67,7 +67,7 @@ To get to know the library with examples, see the [notebook on the extended peng ### 1. **`make_metadata_from_data.py`** #### Purpose -Automatically generate baseline CSVW-SAFE metadata from an existing dataset. +Automatically generate baseline CSVW-EO metadata from an existing dataset. This script infers: - Column datatypes @@ -80,7 +80,7 @@ This script infers: **Important**: This tool is for automated metadata *drafting only*. All outputs must be manually reviewed (and properties can be removed) before publication. -The script first builds a pydantic `TableMetadata` model and then serialises it to a json-ld via a `to_dict()` method. See [TableMetadata.md](https://github.com/dscc-admin-ch/csvw-safe/blob/main/csvw-safe-library/TableMetadata.md) for more detailed explanation on the inner workings. +The script first builds a pydantic `TableMetadata` model and then serialises it to a json-ld via a `to_dict()` method. See [TableMetadata.md](https://github.com/dscc-admin-ch/csvw-eo/blob/main/csvw-eo-library/TableMetadata.md) for more detailed explanation on the inner workings. #### Differential Privacy (DP) Contribution Levels @@ -249,7 +249,7 @@ Notes - Numeric bounds are computed only for non-string columns. - Contribution levels control per-privacy-unit contribution constraints. - Dependency detection may increase runtime on large datasets. -- Output is a JSON-serializable CSVW-SAFE metadata structure. +- Output is a JSON-serializable CSVW-EO metadata structure. #### Future plans: - Allow a DP vs non-DP mode (with/without) DP attributes @@ -259,7 +259,7 @@ Notes #### Purpose -Generate a synthetic dummy dataset from CSVW-SAFE metadata. +Generate a synthetic dummy dataset from CSVW-EO metadata. The generator creates structured data that follows the declared metadata constraints, including: - Column datatypes @@ -283,7 +283,7 @@ The generated dataset: #### Typical Use Cases -- Unit testing of CSVW-SAFE and DP pipelines +- Unit testing of CSVW-EO and DP pipelines - Schema validation without real data access - Debugging metadata-driven transformations - Synthetic data generation for integration tests @@ -307,9 +307,9 @@ python make_dummy_from_metadata.py metadata.json \ #### Purpose -Validate a CSVW-SAFE metadata file against the internal metadata schema. +Validate a CSVW-EO metadata file against the internal metadata schema. -This tool ensures that a metadata file is structurally correct and conforms to the expected CSVW-SAFE specification as defined by the internal `TableMetadata` model. +This tool ensures that a metadata file is structurally correct and conforms to the expected CSVW-EO specification as defined by the internal `TableMetadata` model. It is primarily used as a validation step before using metadata for: - dummy dataset generation @@ -323,7 +323,7 @@ This validator performs schema-level validation only, including: - Structural consistency of metadata objects - Compatibility with the `TableMetadata` model -Validation is implemented via a Pydantic model (`TableMetadata.from_dict`). See [TableMetadata.md](https://github.com/dscc-admin-ch/csvw-safe/blob/main/csvw-safe-library/TableMetadata.md) for more detailed explanation of the underlying pydantic model used to validate the metadata. +Validation is implemented via a Pydantic model (`TableMetadata.from_dict`). See [TableMetadata.md](https://github.com/dscc-admin-ch/csvw-eo/blob/main/csvw-eo-library/TableMetadata.md) for more detailed explanation of the underlying pydantic model used to validate the metadata. Output behaviour: - If metadata is valid → script exits silently (no output) @@ -339,11 +339,11 @@ python validate_metadata.py metadata.json #### Purpose -Validate CSVW-SAFE metadata using a SHACL constraint schema. +Validate CSVW-EO metadata using a SHACL constraint schema. This tool performs structural validation of metadata expressed in JSON-LD format against a SHACL shapes graph defined in Turtle format. -It is the most strict validation layer in the CSVW-SAFE toolchain, intended to ensure full compliance with RDF-based constraints. +It is the most strict validation layer in the CSVW-EO toolchain, intended to ensure full compliance with RDF-based constraints. #### Validation Scope @@ -367,7 +367,7 @@ On failure: SHACL validation FAILED with a Typical Use Cases -- Formal compliance validation of CSVW-SAFE metadata +- Formal compliance validation of CSVW-EO metadata - CI/CD enforcement of metadata correctness - Pre-deployment validation in RDF-based pipelines - Ensuring compatibility with external SHACL-aware systems @@ -382,7 +382,7 @@ Notes #### Purpose -Verify that a generated dummy CSV preserves the structural properties of an original dataset under the CSVW-SAFE assumptions. +Verify that a generated dummy CSV preserves the structural properties of an original dataset under the CSVW-EO assumptions. This tool ensures that synthetic data produced by `make_dummy_from_metadata.py` remains schema-compatible with the original dataset used to derive metadata. @@ -391,7 +391,7 @@ This validator checks structure only. It does not assess statistical similarity The tool checks: - Column names and ordering -- Inferred CSVW-SAFE datatypes +- Inferred CSVW-EO datatypes - Nullability constraints (required vs optional columns) - Optional categorical domain compatibility (subset check) @@ -409,7 +409,7 @@ Ensures that both datasets share identical schema: - Same column names - Same column ordering -Each column is type-checked using CSVW-SAFE inference: +Each column is type-checked using CSVW-EO inference: - Datatypes are inferred via `infer_xmlschema_datatype` - Integer subtype differences are tolerated (e.g., small vs large integer variants) @@ -449,11 +449,11 @@ Notes #### Purpose -Convert CSVW-SAFE metadata into the format expected by SmartNoise SQL. +Convert CSVW-EO metadata into the format expected by SmartNoise SQL. -This script transforms a CSVW-SAFE JSON metadata file into a SmartNoise-compatible YAML configuration, enabling direct use in differential privacy queries with SmartNoise SQL. +This script transforms a CSVW-EO JSON metadata file into a SmartNoise-compatible YAML configuration, enabling direct use in differential privacy queries with SmartNoise SQL. -The script maps CSVW-SAFE metadata into SmartNoise SQL structure: +The script maps CSVW-EO metadata into SmartNoise SQL structure: - Table-level privacy constraints: - `max_contributions` → `max_ids` @@ -521,9 +521,9 @@ python csvw_to_smartnoise_sql.py \ #### Purpose -Create an OpenDP `Context` from CSVW-SAFE metadata and a dataset. +Create an OpenDP `Context` from CSVW-EO metadata and a dataset. -This script bridges CSVW-SAFE metadata with the OpenDP library by: +This script bridges CSVW-EO metadata with the OpenDP library by: - Converting metadata into OpenDP margins - Defining privacy units and privacy loss - Building a ready-to-use OpenDP `Context` for DP queries @@ -554,7 +554,7 @@ The resulting OpenDP `Context` includes: Basic conversion ```bash import polars as pl -from csvw_safe.csvw_to_opendp_context import csvw_to_opendp_context +from csvw_eo.csvw_to_opendp_context import csvw_to_opendp_context data = pl.scan_csv("data.csv") @@ -577,11 +577,11 @@ python make_metadata_from_data.py data.csv --id user_id --mode fine 2. Review manually with a data expert and approve metadata for safety and governance compliance. Optionnaly after removing private information, run (to validate metadata format) ``` -python scripts/validate_metadata_shacl.py metadata.json csvw-safe-constraints.ttl +python scripts/validate_metadata_shacl.py metadata.json csvw-eo-constraints.ttl ``` and with shacl constraints: ``` -python validate_metadata.py metadata.json --shacl csvw-safe-constraints.ttl +python validate_metadata.py metadata.json --shacl csvw-eo-constraints.ttl ``` 3. Generate a dummy dataset from the approved metadata: @@ -598,7 +598,7 @@ python assert_same_structure.py data.csv dummy.csv ### Python API Workflow ``` import pandas as pd -from csvw_safe.make_metadata_from_data import make_metadata_from_data +from csvw_eo.make_metadata_from_data import make_metadata_from_data df = pd.read_csv("data.csv") @@ -609,10 +609,10 @@ metadata = make_metadata_from_data(df, csv_url="data.csv", individual_col="user_ MANUAL REVIEW OF METADATA. VERIFY ONLY PUBLIC INFORMATION. REMOVE OTHERWISE. ``` -from csvw_safe.validate_metadata import validate_metadata -from csvw_safe.validate_metadata_shacl import validate_metadata_shacl -from csvw_safe.make_dummy_from_metadata import make_dummy_from_metadata -from csvw_safe.assert_same_structure import assert_same_structure +from csvw_eo.validate_metadata import validate_metadata +from csvw_eo.validate_metadata_shacl import validate_metadata_shacl +from csvw_eo.make_dummy_from_metadata import make_dummy_from_metadata +from csvw_eo.assert_same_structure import assert_same_structure # Validate metadata errors = validate_metadata(metadata) @@ -631,27 +631,27 @@ assert_same_structure(df, dummy_df) ``` examples/ -└─ Notebooks.ipynb # Example notebooks demonstrating CSVW-SAFE workflows +└─ Notebooks.ipynb # Example notebooks demonstrating CSVW-EO workflows -src/csvw_safe/ - ├─ __init__.py # Package initializer for CSVW-SAFE library +src/csvw_eo/ + ├─ __init__.py # Package initializer for CSVW-EO library - ├─ make_metadata_from_data.py # Generate CSVW-SAFE metadata automatically from a dataset - ├─ make_dummy_from_metadata.py # Generate synthetic dummy datasets from CSVW-SAFE metadata + ├─ make_metadata_from_data.py # Generate CSVW-EO metadata automatically from a dataset + ├─ make_dummy_from_metadata.py # Generate synthetic dummy datasets from CSVW-EO metadata ├─ validate_metadata.py # Validate metadata using internal schema (TableMetadata model) ├─ validate_metadata_shacl.py # Validate metadata using SHACL constraints via RDF graphs ├─ assert_same_structure.py # Compare original and dummy CSVs for structural consistency - ├─ csvw_to_opendp_context.py # Convert CSVW-SAFE metadata into OpenDP analysis context - ├─ csvw_to_opendp_margins.py # Translate CSVW-SAFE metadata into OpenDP margin definitions - ├─ csvw_to_smartnoise_sql.py # Convert CSVW-SAFE metadata into SmartNoise SQL format + ├─ csvw_to_opendp_context.py # Convert CSVW-EO metadata into OpenDP analysis context + ├─ csvw_to_opendp_margins.py # Translate CSVW-EO metadata into OpenDP margin definitions + ├─ csvw_to_smartnoise_sql.py # Convert CSVW-EO metadata into SmartNoise SQL format ├─ generate_series.py # Generate synthetic column values based on metadata rules - ├─ metadata_structure.py # Core data models defining CSVW-SAFE metadata schema + ├─ metadata_structure.py # Core data models defining CSVW-EO metadata schema ├─ constants.py # Shared constants used across metadata pipeline - ├─ datatypes.py # Datatype inference and CSVW-SAFE type utilities + ├─ datatypes.py # Datatype inference and CSVW-EO type utilities └─ utils.py # General helper utilities for metadata processing -tests/ # Unit and integration tests for CSVW-SAFE library +tests/ # Unit and integration tests for CSVW-EO library pyproject.toml # Project configuration and dependencies README.md # Project overview and documentation entry point diff --git a/csvw-safe-library/examples/Make-Penguin-Dummy.ipynb b/csvw-eo-library/examples/Make-Penguin-Dummy.ipynb similarity index 97% rename from csvw-safe-library/examples/Make-Penguin-Dummy.ipynb rename to csvw-eo-library/examples/Make-Penguin-Dummy.ipynb index c0f4db6..2631736 100644 --- a/csvw-safe-library/examples/Make-Penguin-Dummy.ipynb +++ b/csvw-eo-library/examples/Make-Penguin-Dummy.ipynb @@ -138,7 +138,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "/home/onyxia/work/csvw-safe/csvw-safe-library/examples/utils.py:25: FutureWarning: DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated, and in a future version of pandas the grouping columns will be excluded from the operation. Either pass `include_groups=False` to exclude the groupings or explicitly select the grouping columns after groupby to silence this warning.\n", + "/home/onyxia/work/csvw-eo/csvw-eo-library/examples/utils.py:25: FutureWarning: DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated, and in a future version of pandas the grouping columns will be excluded from the operation. Either pass `include_groups=False` to exclude the groupings or explicitly select the grouping columns after groupby to silence this warning.\n", " df.groupby(fixed_fields, dropna=False, group_keys=False).apply(random_merge)\n" ] } diff --git a/csvw-safe-library/examples/Use-Library.ipynb b/csvw-eo-library/examples/Use-Library.ipynb similarity index 97% rename from csvw-safe-library/examples/Use-Library.ipynb rename to csvw-eo-library/examples/Use-Library.ipynb index 4acb375..235f2b8 100644 --- a/csvw-safe-library/examples/Use-Library.ipynb +++ b/csvw-eo-library/examples/Use-Library.ipynb @@ -5,7 +5,7 @@ "id": "0a6423f4-b905-4b02-8d0f-d12f5f3f38f1", "metadata": {}, "source": [ - "# CSVW-SAFE DEMO" + "# CSVW-EO DEMO" ] }, { @@ -23,7 +23,7 @@ "metadata": {}, "outputs": [], "source": [ - "#!pip install csvw-safe" + "#!pip install csvw-eo" ] }, { @@ -35,7 +35,7 @@ "source": [ "import json\n", "import pandas as pd\n", - "from csvw_safe import assert_same_structure, make_dummy_from_metadata, make_metadata_from_data, validate_metadata" + "from csvw_eomport assert_same_structure, make_dummy_from_metadata, make_metadata_from_data, validate_metadata" ] }, { @@ -350,7 +350,7 @@ "\u001b[31m---------------------------------------------------------------------------\u001b[39m", "\u001b[31mAssertionError\u001b[39m Traceback (most recent call last)", "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[12]\u001b[39m\u001b[32m, line 2\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;66;03m# Should error as the metadata did not contain categories\u001b[39;00m\n\u001b[32m----> \u001b[39m\u001b[32m2\u001b[39m assert_same_structure(df, dummy_df, check_categories=\u001b[38;5;28;01mTrue\u001b[39;00m)\n", - "\u001b[36mFile \u001b[39m\u001b[32m/opt/python/lib/python3.13/site-packages/csvw_safe/assert_same_structure.py:96\u001b[39m, in \u001b[36massert_same_structure\u001b[39m\u001b[34m(df1, df2, check_categories)\u001b[39m\n\u001b[32m 93\u001b[39m vals2 = \u001b[38;5;28mset\u001b[39m(df2[col].dropna().unique())\n\u001b[32m 95\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m vals2.issubset(vals1):\n\u001b[32m---> \u001b[39m\u001b[32m96\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mAssertionError\u001b[39;00m(\n\u001b[32m 97\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mColumn \u001b[39m\u001b[33m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mcol\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m'\u001b[39m\u001b[33m dummy values \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mvals2\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m are not subset of original \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mvals1\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m\n\u001b[32m 98\u001b[39m )\n", + "\u001b[36mFile \u001b[39m\u001b[32m/opt/python/lib/python3.13/site-packages/csvw_eossert_same_structure.py:96\u001b[39m, in \u001b[36massert_same_structure\u001b[39m\u001b[34m(df1, df2, check_categories)\u001b[39m\n\u001b[32m 93\u001b[39m vals2 = \u001b[38;5;28mset\u001b[39m(df2[col].dropna().unique())\n\u001b[32m 95\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m vals2.issubset(vals1):\n\u001b[32m---> \u001b[39m\u001b[32m96\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mAssertionError\u001b[39;00m(\n\u001b[32m 97\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mColumn \u001b[39m\u001b[33m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mcol\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m'\u001b[39m\u001b[33m dummy values \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mvals2\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m are not subset of original \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mvals1\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m\n\u001b[32m 98\u001b[39m )\n", "\u001b[31mAssertionError\u001b[39m: Column 'species' dummy values {'c', 'h', 'i', 'a', 'e', 'f', 'g', 'j', 'b', 'd'} are not subset of original {'Adelie', 'Gentoo', 'Chinstrap'}" ] } diff --git a/csvw-eo-library/examples/metadata/penguin_metadata_column_level.json-ld b/csvw-eo-library/examples/metadata/penguin_metadata_column_level.json-ld new file mode 100644 index 0000000..d1fcfb7 --- /dev/null +++ b/csvw-eo-library/examples/metadata/penguin_metadata_column_level.json-ld @@ -0,0 +1 @@ +{"@context": ["http://www.w3.org/ns/csvw", "/opt/python/lib/python3.13/csvw-eo-context.jsonld"], "@type": "Table", "privacyUnit": "penguin_id", "maxContributions": 3, "maxLength": 344, "publicLength": 344, "tableSchema": {"columns": [{"@type": "Column", "name": "species", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "keyValues": ["Adelie", "Chinstrap", "Gentoo"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3, "maxLength": 152, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Column", "name": "island", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "keyValues": ["Biscoe", "Dream", "Torgersen"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3, "maxLength": 168, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Column", "name": "bill_length_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.294, "minimum": 32.1, "maximum": 59.6}, {"@type": "Column", "name": "bill_depth_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 13.1, "maximum": 21.5}, {"@type": "Column", "name": "flipper_length_mm", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.439, "minimum": 176.0, "maximum": 231.0}, {"@type": "Column", "name": "body_mass_g", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 2700.0, "maximum": 6300.0}, {"@type": "Column", "name": "sex", "datatype": "boolean", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": false, "maximum": true, "keyValues": [false, true], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 2, "maxLength": 179, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Column", "name": "penguin_id", "datatype": "positiveInteger", "required": true, "privacyId": true, "nullableProportion": 0.0, "minimum": 1, "maximum": 341}, {"@type": "Column", "name": "timestamp", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T00:00:00", "maximum": "2025-12-30T00:00:00"}, {"@type": "Column", "name": "timestamp_with_time", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T06:47:46", "maximum": "2025-12-30T19:27:11"}, {"@type": "Column", "name": "favourite_number", "datatype": "integer", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": 0, "maximum": 5, "keyValues": [0, 1, 2, 3, 4, 5], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 6, "maxLength": 66, "maxGroupsPerUnit": 3, "maxContributions": 3}]}} \ No newline at end of file diff --git a/csvw-eo-library/examples/metadata/penguin_metadata_column_level_column_group.json-ld b/csvw-eo-library/examples/metadata/penguin_metadata_column_level_column_group.json-ld new file mode 100644 index 0000000..6f9eacc --- /dev/null +++ b/csvw-eo-library/examples/metadata/penguin_metadata_column_level_column_group.json-ld @@ -0,0 +1 @@ +{"@context": ["http://www.w3.org/ns/csvw", "/opt/python/lib/python3.13/csvw-eo-context.jsonld"], "@type": "Table", "privacyUnit": "penguin_id", "maxContributions": 3, "maxLength": 344, "publicLength": 344, "tableSchema": {"columns": [{"@type": "Column", "name": "species", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "keyValues": ["Adelie", "Chinstrap", "Gentoo"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3, "maxLength": 152, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Column", "name": "island", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "keyValues": ["Biscoe", "Dream", "Torgersen"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3, "maxLength": 168, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Column", "name": "bill_length_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.294, "minimum": 32.1, "maximum": 59.6}, {"@type": "Column", "name": "bill_depth_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 13.1, "maximum": 21.5}, {"@type": "Column", "name": "flipper_length_mm", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.439, "minimum": 176.0, "maximum": 231.0}, {"@type": "Column", "name": "body_mass_g", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 2700.0, "maximum": 6300.0}, {"@type": "Column", "name": "sex", "datatype": "boolean", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": false, "maximum": true, "keyValues": [false, true], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 2, "maxLength": 179, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Column", "name": "penguin_id", "datatype": "positiveInteger", "required": true, "privacyId": true, "nullableProportion": 0.0, "minimum": 1, "maximum": 341}, {"@type": "Column", "name": "timestamp", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T00:00:00", "maximum": "2025-12-30T00:00:00"}, {"@type": "Column", "name": "timestamp_with_time", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T06:47:46", "maximum": "2025-12-30T19:27:11"}, {"@type": "Column", "name": "favourite_number", "datatype": "integer", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": 0, "maximum": 5, "keyValues": [0, 1, 2, 3, 4, 5], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 6, "maxLength": 66, "maxGroupsPerUnit": 3, "maxContributions": 3}]}, "additionalInformation": [{"@type": "ColumnGroup", "columnsInGroup": ["species", "island"], "keyValues": [{"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Biscoe"}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Dream"}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Torgersen"}}, {"species": {"partitionValue": "Chinstrap"}, "island": {"partitionValue": "Dream"}}, {"species": {"partitionValue": "Gentoo"}, "island": {"partitionValue": "Biscoe"}}], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 5, "maxLength": 124, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "ColumnGroup", "columnsInGroup": ["species", "island", "favourite_number"], "keyValues": [{"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 0}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 1}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 2}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 3}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 4}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 5}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 0}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 1}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 2}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 3}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 4}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 5}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Torgersen"}, "favourite_number": {"partitionValue": 0}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Torgersen"}, "favourite_number": {"partitionValue": 1}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Torgersen"}, "favourite_number": {"partitionValue": 2}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Torgersen"}, "favourite_number": {"partitionValue": 3}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Torgersen"}, "favourite_number": {"partitionValue": 4}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Torgersen"}, "favourite_number": {"partitionValue": 5}}, {"species": {"partitionValue": "Chinstrap"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 0}}, {"species": {"partitionValue": "Chinstrap"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 1}}, {"species": {"partitionValue": "Chinstrap"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 2}}, {"species": {"partitionValue": "Chinstrap"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 3}}, {"species": {"partitionValue": "Chinstrap"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 4}}, {"species": {"partitionValue": "Chinstrap"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 5}}, {"species": {"partitionValue": "Gentoo"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 0}}, {"species": {"partitionValue": "Gentoo"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 1}}, {"species": {"partitionValue": "Gentoo"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 2}}, {"species": {"partitionValue": "Gentoo"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 3}}, {"species": {"partitionValue": "Gentoo"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 4}}, {"species": {"partitionValue": "Gentoo"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 5}}], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 30, "maxLength": 30, "maxGroupsPerUnit": 3, "maxContributions": 3}]} \ No newline at end of file diff --git a/csvw-eo-library/examples/metadata/penguin_metadata_fine_contrib_levels.json-ld b/csvw-eo-library/examples/metadata/penguin_metadata_fine_contrib_levels.json-ld new file mode 100644 index 0000000..e6b088b --- /dev/null +++ b/csvw-eo-library/examples/metadata/penguin_metadata_fine_contrib_levels.json-ld @@ -0,0 +1 @@ +{"@context": ["http://www.w3.org/ns/csvw", "/opt/python/lib/python3.13/csvw-eo-context.jsonld"], "@type": "Table", "privacyUnit": "penguin_id", "maxContributions": 3, "maxLength": 344, "publicLength": 344, "tableSchema": {"columns": [{"@type": "Column", "name": "species", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": "Adelie"}, "maxLength": 152, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Chinstrap"}, "maxLength": 68, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Gentoo"}, "maxLength": 124, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": ["Adelie", "Chinstrap", "Gentoo"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "island", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "keyValues": ["Biscoe", "Dream", "Torgersen"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3, "maxLength": 168, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Column", "name": "bill_length_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.294, "minimum": 32.1, "maximum": 59.6, "partitions": [{"@type": "Partition", "predicate": {"lowerBound": 30.0, "upperBound": 40.0}, "maxLength": 74, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"lowerBound": 40.0, "upperBound": 50.0}, "maxLength": 128, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"lowerBound": 50.0, "upperBound": 60.0}, "maxLength": 41, "maxGroupsPerUnit": 3, "maxContributions": 2}], "maxNumPartitions": 3}, {"@type": "Column", "name": "bill_depth_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 13.1, "maximum": 21.5}, {"@type": "Column", "name": "flipper_length_mm", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.439, "minimum": 176.0, "maximum": 231.0}, {"@type": "Column", "name": "body_mass_g", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 2700.0, "maximum": 6300.0}, {"@type": "Column", "name": "sex", "datatype": "boolean", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": false, "maximum": true, "keyValues": [false, true], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 2}, {"@type": "Column", "name": "penguin_id", "datatype": "positiveInteger", "required": true, "privacyId": true, "nullableProportion": 0.0, "minimum": 1, "maximum": 341}, {"@type": "Column", "name": "timestamp", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T00:00:00", "maximum": "2025-12-30T00:00:00"}, {"@type": "Column", "name": "timestamp_with_time", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T06:47:46", "maximum": "2025-12-30T19:27:11"}, {"@type": "Column", "name": "favourite_number", "datatype": "integer", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": 0, "maximum": 5, "keyValues": [0, 1, 2, 3, 4, 5], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 6}]}} \ No newline at end of file diff --git a/csvw-eo-library/examples/metadata/penguin_metadata_fine_levels_column_group_continuous.json-ld b/csvw-eo-library/examples/metadata/penguin_metadata_fine_levels_column_group_continuous.json-ld new file mode 100644 index 0000000..b11de23 --- /dev/null +++ b/csvw-eo-library/examples/metadata/penguin_metadata_fine_levels_column_group_continuous.json-ld @@ -0,0 +1 @@ +{"@context": ["http://www.w3.org/ns/csvw", "/home/onyxia/work/csvw-eo/csvw-eo-library/csvw-eo-context.jsonld"], "@type": "Table", "privacyUnit": "penguin_id", "maxContributions": 3, "maxLength": 344, "publicLength": 344, "tableSchema": {"columns": [{"@type": "Column", "name": "species", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "rowDependencies": [{"dependsOn": "island", "dependencyType": "mapping", "valueMap": {"Biscoe": ["Adelie", "Gentoo"], "Dream": ["Adelie", "Chinstrap"], "Torgersen": ["Adelie"]}}, {"dependsOn": "penguin_id", "dependencyType": "fixedPerEntity"}, {"dependsOn": "timestamp_with_time", "dependencyType": "fixedPerEntity"}], "partitions": [{"@type": "Partition", "predicate": {"partitionValue": "Adelie"}, "maxLength": 152, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Chinstrap"}, "maxLength": 68, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Gentoo"}, "maxLength": 124, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": ["Adelie", "Chinstrap", "Gentoo"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "island", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "rowDependencies": [{"dependsOn": "species", "dependencyType": "mapping", "valueMap": {"Adelie": ["Torgersen", "Biscoe", "Dream"], "Chinstrap": ["Dream"], "Gentoo": ["Biscoe"]}}, {"dependsOn": "penguin_id", "dependencyType": "fixedPerEntity"}, {"dependsOn": "timestamp_with_time", "dependencyType": "fixedPerEntity"}], "keyValues": ["Biscoe", "Dream", "Torgersen"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3, "maxLength": 168, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Column", "name": "bill_length_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.294, "minimum": 32.1, "maximum": 59.6, "partitions": [{"@type": "Partition", "predicate": {"lowerBound": 30.0, "upperBound": 40.0}, "maxLength": 74, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"lowerBound": 40.0, "upperBound": 50.0}, "maxLength": 128, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"lowerBound": 50.0, "upperBound": 60.0}, "maxLength": 41, "maxGroupsPerUnit": 3, "maxContributions": 2}], "maxNumPartitions": 3}, {"@type": "Column", "name": "bill_depth_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 13.1, "maximum": 21.5}, {"@type": "Column", "name": "flipper_length_mm", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.439, "minimum": 176.0, "maximum": 231.0}, {"@type": "Column", "name": "body_mass_g", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 2700.0, "maximum": 6300.0}, {"@type": "Column", "name": "sex", "datatype": "boolean", "required": true, "privacyId": false, "nullableProportion": 0.0, "rowDependencies": [{"dependsOn": "penguin_id", "dependencyType": "fixedPerEntity"}, {"dependsOn": "timestamp_with_time", "dependencyType": "fixedPerEntity"}], "minimum": false, "maximum": true, "keyValues": [false, true], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 2}, {"@type": "Column", "name": "penguin_id", "datatype": "positiveInteger", "required": true, "privacyId": true, "nullableProportion": 0.0, "minimum": 1, "maximum": 343}, {"@type": "Column", "name": "timestamp", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T00:00:00", "maximum": "2025-12-30T00:00:00", "partitions": [{"@type": "Partition", "predicate": {"lowerBound": "2025-01-02T00:00:00", "upperBound": "2025-06-02T00:00:00"}, "maxLength": 139, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"lowerBound": "2025-06-02T00:00:00", "upperBound": "2025-12-30T00:00:00"}, "maxLength": 204, "maxGroupsPerUnit": 3, "maxContributions": 2}], "maxNumPartitions": 2}, {"@type": "Column", "name": "timestamp_with_time", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "rowDependencies": [{"dependsOn": "timestamp", "dependencyType": "bigger"}], "minimum": "2025-01-02T06:47:46", "maximum": "2025-12-30T19:27:11"}, {"@type": "Column", "name": "favourite_number", "datatype": "integer", "required": true, "privacyId": false, "nullableProportion": 0.0, "rowDependencies": [{"dependsOn": "timestamp_with_time", "dependencyType": "fixedPerEntity"}], "minimum": 0, "maximum": 5, "keyValues": [0, 1, 2, 3, 4, 5], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 6}]}, "additionalInformation": [{"@type": "ColumnGroup", "columnsInGroup": ["species", "bill_length_mm"], "partitions": [{"@type": "Partition", "predicate": {"species": {"partitionValue": "Adelie"}, "bill_length_mm": {"lowerBound": 30.0, "upperBound": 40.0}}, "maxLength": 74, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"species": {"partitionValue": "Adelie"}, "bill_length_mm": {"lowerBound": 40.0, "upperBound": 50.0}}, "maxLength": 30, "maxGroupsPerUnit": 2, "maxContributions": 2}, {"@type": "Partition", "predicate": {"species": {"partitionValue": "Chinstrap"}, "bill_length_mm": {"lowerBound": 40.0, "upperBound": 50.0}}, "maxLength": 25, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"species": {"partitionValue": "Chinstrap"}, "bill_length_mm": {"lowerBound": 50.0, "upperBound": 60.0}}, "maxLength": 21, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"species": {"partitionValue": "Gentoo"}, "bill_length_mm": {"lowerBound": 40.0, "upperBound": 50.0}}, "maxLength": 73, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"species": {"partitionValue": "Gentoo"}, "bill_length_mm": {"lowerBound": 50.0, "upperBound": 60.0}}, "maxLength": 20, "maxGroupsPerUnit": 2, "maxContributions": 2}], "keyValues": [{"species": {"partitionValue": "Adelie"}, "bill_length_mm": {"lowerBound": 30.0, "upperBound": 40.0}}, {"species": {"partitionValue": "Adelie"}, "bill_length_mm": {"lowerBound": 40.0, "upperBound": 50.0}}, {"species": {"partitionValue": "Chinstrap"}, "bill_length_mm": {"lowerBound": 40.0, "upperBound": 50.0}}, {"species": {"partitionValue": "Chinstrap"}, "bill_length_mm": {"lowerBound": 50.0, "upperBound": 60.0}}, {"species": {"partitionValue": "Gentoo"}, "bill_length_mm": {"lowerBound": 40.0, "upperBound": 50.0}}, {"species": {"partitionValue": "Gentoo"}, "bill_length_mm": {"lowerBound": 50.0, "upperBound": 60.0}}], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 6}]} \ No newline at end of file diff --git a/csvw-eo-library/examples/metadata/penguin_metadata_partition_level.json-ld b/csvw-eo-library/examples/metadata/penguin_metadata_partition_level.json-ld new file mode 100644 index 0000000..b22bc11 --- /dev/null +++ b/csvw-eo-library/examples/metadata/penguin_metadata_partition_level.json-ld @@ -0,0 +1 @@ +{"@context": ["http://www.w3.org/ns/csvw", "/opt/python/lib/python3.13/csvw-eo-context.jsonld"], "@type": "Table", "privacyUnit": "penguin_id", "maxContributions": 3, "maxLength": 344, "publicLength": 344, "tableSchema": {"columns": [{"@type": "Column", "name": "species", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": "Adelie"}, "maxLength": 152, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Chinstrap"}, "maxLength": 68, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Gentoo"}, "maxLength": 124, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": ["Adelie", "Chinstrap", "Gentoo"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "island", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": "Biscoe"}, "maxLength": 168, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Dream"}, "maxLength": 124, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Torgersen"}, "maxLength": 52, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": ["Biscoe", "Dream", "Torgersen"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "bill_length_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.294, "minimum": 32.1, "maximum": 59.6}, {"@type": "Column", "name": "bill_depth_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 13.1, "maximum": 21.5}, {"@type": "Column", "name": "flipper_length_mm", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.439, "minimum": 176.0, "maximum": 231.0}, {"@type": "Column", "name": "body_mass_g", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 2700.0, "maximum": 6300.0}, {"@type": "Column", "name": "sex", "datatype": "boolean", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": false, "maximum": true, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": false}, "maxLength": 165, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": true}, "maxLength": 179, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": [false, true], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 2}, {"@type": "Column", "name": "penguin_id", "datatype": "positiveInteger", "required": true, "privacyId": true, "nullableProportion": 0.0, "minimum": 1, "maximum": 341}, {"@type": "Column", "name": "timestamp", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T00:00:00", "maximum": "2025-12-30T00:00:00"}, {"@type": "Column", "name": "timestamp_with_time", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T06:47:46", "maximum": "2025-12-30T19:27:11"}, {"@type": "Column", "name": "favourite_number", "datatype": "integer", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": 0, "maximum": 5, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": 0}, "maxLength": 60, "maxGroupsPerUnit": 3, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 1}, "maxLength": 57, "maxGroupsPerUnit": 2, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 2}, "maxLength": 59, "maxGroupsPerUnit": 3, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 3}, "maxLength": 45, "maxGroupsPerUnit": 3, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 4}, "maxLength": 57, "maxGroupsPerUnit": 2, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 5}, "maxLength": 66, "maxGroupsPerUnit": 3, "maxContributions": 3}], "keyValues": [0, 1, 2, 3, 4, 5], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 6}]}} \ No newline at end of file diff --git a/csvw-eo-library/examples/metadata/penguin_metadata_partition_level_column_group.json-ld b/csvw-eo-library/examples/metadata/penguin_metadata_partition_level_column_group.json-ld new file mode 100644 index 0000000..f92cb64 --- /dev/null +++ b/csvw-eo-library/examples/metadata/penguin_metadata_partition_level_column_group.json-ld @@ -0,0 +1 @@ +{"@context": ["http://www.w3.org/ns/csvw", "/opt/python/lib/python3.13/csvw-eo-context.jsonld"], "@type": "Table", "privacyUnit": "penguin_id", "maxContributions": 3, "maxLength": 344, "publicLength": 344, "tableSchema": {"columns": [{"@type": "Column", "name": "species", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": "Adelie"}, "maxLength": 152, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Chinstrap"}, "maxLength": 68, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Gentoo"}, "maxLength": 124, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": ["Adelie", "Chinstrap", "Gentoo"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "island", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": "Biscoe"}, "maxLength": 168, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Dream"}, "maxLength": 124, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Torgersen"}, "maxLength": 52, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": ["Biscoe", "Dream", "Torgersen"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "bill_length_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.294, "minimum": 32.1, "maximum": 59.6}, {"@type": "Column", "name": "bill_depth_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 13.1, "maximum": 21.5}, {"@type": "Column", "name": "flipper_length_mm", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.439, "minimum": 176.0, "maximum": 231.0}, {"@type": "Column", "name": "body_mass_g", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 2700.0, "maximum": 6300.0}, {"@type": "Column", "name": "sex", "datatype": "boolean", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": false, "maximum": true, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": false}, "maxLength": 165, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": true}, "maxLength": 179, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": [false, true], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 2}, {"@type": "Column", "name": "penguin_id", "datatype": "positiveInteger", "required": true, "privacyId": true, "nullableProportion": 0.0, "minimum": 1, "maximum": 341}, {"@type": "Column", "name": "timestamp", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T00:00:00", "maximum": "2025-12-30T00:00:00"}, {"@type": "Column", "name": "timestamp_with_time", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T06:47:46", "maximum": "2025-12-30T19:27:11"}, {"@type": "Column", "name": "favourite_number", "datatype": "integer", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": 0, "maximum": 5, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": 0}, "maxLength": 60, "maxGroupsPerUnit": 3, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 1}, "maxLength": 57, "maxGroupsPerUnit": 2, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 2}, "maxLength": 59, "maxGroupsPerUnit": 3, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 3}, "maxLength": 45, "maxGroupsPerUnit": 3, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 4}, "maxLength": 57, "maxGroupsPerUnit": 2, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 5}, "maxLength": 66, "maxGroupsPerUnit": 3, "maxContributions": 3}], "keyValues": [0, 1, 2, 3, 4, 5], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 6}]}, "additionalInformation": [{"@type": "ColumnGroup", "columnsInGroup": ["species", "island"], "partitions": [{"@type": "Partition", "predicate": {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Biscoe"}}, "maxLength": 44, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Dream"}}, "maxLength": 56, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Torgersen"}}, "maxLength": 52, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"species": {"partitionValue": "Chinstrap"}, "island": {"partitionValue": "Dream"}}, "maxLength": 68, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"species": {"partitionValue": "Gentoo"}, "island": {"partitionValue": "Biscoe"}}, "maxLength": 124, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": [{"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Biscoe"}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Dream"}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Torgersen"}}, {"species": {"partitionValue": "Chinstrap"}, "island": {"partitionValue": "Dream"}}, {"species": {"partitionValue": "Gentoo"}, "island": {"partitionValue": "Biscoe"}}], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 5}]} \ No newline at end of file diff --git a/csvw-eo-library/examples/metadata/penguin_metadata_partition_level_with_continuous.json-ld b/csvw-eo-library/examples/metadata/penguin_metadata_partition_level_with_continuous.json-ld new file mode 100644 index 0000000..5d51b8f --- /dev/null +++ b/csvw-eo-library/examples/metadata/penguin_metadata_partition_level_with_continuous.json-ld @@ -0,0 +1 @@ +{"@context": ["http://www.w3.org/ns/csvw", "/opt/python/lib/python3.13/csvw-eo-context.jsonld"], "@type": "Table", "privacyUnit": "penguin_id", "maxContributions": 3, "maxLength": 344, "publicLength": 344, "tableSchema": {"columns": [{"@type": "Column", "name": "species", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": "Adelie"}, "maxLength": 152, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Chinstrap"}, "maxLength": 68, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Gentoo"}, "maxLength": 124, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": ["Adelie", "Chinstrap", "Gentoo"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "island", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": "Biscoe"}, "maxLength": 168, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Dream"}, "maxLength": 124, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Torgersen"}, "maxLength": 52, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": ["Biscoe", "Dream", "Torgersen"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "bill_length_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.294, "minimum": 32.1, "maximum": 59.6, "partitions": [{"@type": "Partition", "predicate": {"lowerBound": 30.0, "upperBound": 40.0}, "maxLength": 74, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"lowerBound": 40.0, "upperBound": 50.0}, "maxLength": 128, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"lowerBound": 50.0, "upperBound": 60.0}, "maxLength": 41, "maxGroupsPerUnit": 3, "maxContributions": 2}], "maxNumPartitions": 3}, {"@type": "Column", "name": "bill_depth_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 13.1, "maximum": 21.5}, {"@type": "Column", "name": "flipper_length_mm", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.439, "minimum": 176.0, "maximum": 231.0}, {"@type": "Column", "name": "body_mass_g", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 2700.0, "maximum": 6300.0}, {"@type": "Column", "name": "sex", "datatype": "boolean", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": false, "maximum": true, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": false}, "maxLength": 165, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": true}, "maxLength": 179, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": [false, true], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 2}, {"@type": "Column", "name": "penguin_id", "datatype": "positiveInteger", "required": true, "privacyId": true, "nullableProportion": 0.0, "minimum": 1, "maximum": 341}, {"@type": "Column", "name": "timestamp", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T00:00:00", "maximum": "2025-12-30T00:00:00", "partitions": [{"@type": "Partition", "predicate": {"lowerBound": "2025-01-02T00:00:00", "upperBound": "2025-06-02T00:00:00"}, "maxLength": 139, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"lowerBound": "2025-06-02T00:00:00", "upperBound": "2025-12-30T00:00:00"}, "maxLength": 204, "maxGroupsPerUnit": 3, "maxContributions": 2}], "maxNumPartitions": 2}, {"@type": "Column", "name": "timestamp_with_time", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T06:47:46", "maximum": "2025-12-30T19:27:11"}, {"@type": "Column", "name": "favourite_number", "datatype": "integer", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": 0, "maximum": 5, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": 0}, "maxLength": 60, "maxGroupsPerUnit": 3, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 1}, "maxLength": 57, "maxGroupsPerUnit": 2, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 2}, "maxLength": 59, "maxGroupsPerUnit": 3, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 3}, "maxLength": 45, "maxGroupsPerUnit": 3, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 4}, "maxLength": 57, "maxGroupsPerUnit": 2, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 5}, "maxLength": 66, "maxGroupsPerUnit": 3, "maxContributions": 3}], "keyValues": [0, 1, 2, 3, 4, 5], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 6}]}} \ No newline at end of file diff --git a/csvw-eo-library/examples/metadata/penguin_metadata_table_level.json-ld b/csvw-eo-library/examples/metadata/penguin_metadata_table_level.json-ld new file mode 100644 index 0000000..25d079a --- /dev/null +++ b/csvw-eo-library/examples/metadata/penguin_metadata_table_level.json-ld @@ -0,0 +1 @@ +{"@context": ["http://www.w3.org/ns/csvw", "/opt/python/lib/python3.13/csvw-eo-context.jsonld"], "@type": "Table", "privacyUnit": "penguin_id", "maxContributions": 3, "maxLength": 344, "publicLength": 344, "tableSchema": {"columns": [{"@type": "Column", "name": "species", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0}, {"@type": "Column", "name": "island", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0}, {"@type": "Column", "name": "bill_length_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.294, "minimum": 32.1, "maximum": 59.6}, {"@type": "Column", "name": "bill_depth_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 13.1, "maximum": 21.5}, {"@type": "Column", "name": "flipper_length_mm", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.439, "minimum": 176.0, "maximum": 231.0}, {"@type": "Column", "name": "body_mass_g", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 2700.0, "maximum": 6300.0}, {"@type": "Column", "name": "sex", "datatype": "boolean", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": false, "maximum": true}, {"@type": "Column", "name": "penguin_id", "datatype": "positiveInteger", "required": true, "privacyId": true, "nullableProportion": 0.0, "minimum": 1, "maximum": 341}, {"@type": "Column", "name": "timestamp", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T00:00:00", "maximum": "2025-12-30T00:00:00"}, {"@type": "Column", "name": "timestamp_with_time", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T06:47:46", "maximum": "2025-12-30T19:27:11"}, {"@type": "Column", "name": "favourite_number", "datatype": "integer", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": 0, "maximum": 5}]}} \ No newline at end of file diff --git a/csvw-eo-library/examples/metadata/penguin_metadata_table_with_keys_level.json-ld b/csvw-eo-library/examples/metadata/penguin_metadata_table_with_keys_level.json-ld new file mode 100644 index 0000000..0dec476 --- /dev/null +++ b/csvw-eo-library/examples/metadata/penguin_metadata_table_with_keys_level.json-ld @@ -0,0 +1 @@ +{"@context": ["http://www.w3.org/ns/csvw", "/opt/python/lib/python3.13/csvw-eo-context.jsonld"], "@type": "Table", "privacyUnit": "penguin_id", "maxContributions": 3, "maxLength": 344, "publicLength": 344, "tableSchema": {"columns": [{"@type": "Column", "name": "species", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "keyValues": ["Adelie", "Chinstrap", "Gentoo"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "island", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "keyValues": ["Biscoe", "Dream", "Torgersen"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "bill_length_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.294, "minimum": 32.1, "maximum": 59.6}, {"@type": "Column", "name": "bill_depth_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 13.1, "maximum": 21.5}, {"@type": "Column", "name": "flipper_length_mm", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.439, "minimum": 176.0, "maximum": 231.0}, {"@type": "Column", "name": "body_mass_g", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 2700.0, "maximum": 6300.0}, {"@type": "Column", "name": "sex", "datatype": "boolean", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": false, "maximum": true, "keyValues": [false, true], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 2}, {"@type": "Column", "name": "penguin_id", "datatype": "positiveInteger", "required": true, "privacyId": true, "nullableProportion": 0.0, "minimum": 1, "maximum": 341}, {"@type": "Column", "name": "timestamp", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T00:00:00", "maximum": "2025-12-30T00:00:00"}, {"@type": "Column", "name": "timestamp_with_time", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T06:47:46", "maximum": "2025-12-30T19:27:11"}, {"@type": "Column", "name": "favourite_number", "datatype": "integer", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": 0, "maximum": 5, "keyValues": [0, 1, 2, 3, 4, 5], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 6}]}} \ No newline at end of file diff --git a/csvw-eo-library/examples/metadata/penguin_metadata_table_with_keys_with_dependencies.json-ld b/csvw-eo-library/examples/metadata/penguin_metadata_table_with_keys_with_dependencies.json-ld new file mode 100644 index 0000000..f9a69f5 --- /dev/null +++ b/csvw-eo-library/examples/metadata/penguin_metadata_table_with_keys_with_dependencies.json-ld @@ -0,0 +1 @@ +{"@context": ["http://www.w3.org/ns/csvw", "/opt/python/lib/python3.13/csvw-eo-context.jsonld"], "@type": "Table", "privacyUnit": "penguin_id", "maxContributions": 3, "maxLength": 344, "publicLength": 344, "tableSchema": {"columns": [{"@type": "Column", "name": "species", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "rowDependencies": [{"dependsOn": "island", "dependencyType": "mapping", "valueMap": {"Biscoe": ["Adelie", "Gentoo"], "Dream": ["Adelie", "Chinstrap"], "Torgersen": ["Adelie"]}}, {"dependsOn": "penguin_id", "dependencyType": "fixedPerEntity"}, {"dependsOn": "timestamp_with_time", "dependencyType": "fixedPerEntity"}], "keyValues": ["Adelie", "Chinstrap", "Gentoo"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "island", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "rowDependencies": [{"dependsOn": "species", "dependencyType": "mapping", "valueMap": {"Adelie": ["Torgersen", "Biscoe", "Dream"], "Chinstrap": ["Dream"], "Gentoo": ["Biscoe"]}}, {"dependsOn": "penguin_id", "dependencyType": "fixedPerEntity"}, {"dependsOn": "timestamp_with_time", "dependencyType": "fixedPerEntity"}], "keyValues": ["Biscoe", "Dream", "Torgersen"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "bill_length_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.294, "minimum": 32.1, "maximum": 59.6}, {"@type": "Column", "name": "bill_depth_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 13.1, "maximum": 21.5}, {"@type": "Column", "name": "flipper_length_mm", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.439, "minimum": 176.0, "maximum": 231.0}, {"@type": "Column", "name": "body_mass_g", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 2700.0, "maximum": 6300.0}, {"@type": "Column", "name": "sex", "datatype": "boolean", "required": true, "privacyId": false, "nullableProportion": 0.0, "rowDependencies": [{"dependsOn": "penguin_id", "dependencyType": "fixedPerEntity"}, {"dependsOn": "timestamp_with_time", "dependencyType": "fixedPerEntity"}], "minimum": false, "maximum": true, "keyValues": [false, true], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 2}, {"@type": "Column", "name": "penguin_id", "datatype": "positiveInteger", "required": true, "privacyId": true, "nullableProportion": 0.0, "minimum": 1, "maximum": 341}, {"@type": "Column", "name": "timestamp", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T00:00:00", "maximum": "2025-12-30T00:00:00"}, {"@type": "Column", "name": "timestamp_with_time", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "rowDependencies": [{"dependsOn": "timestamp", "dependencyType": "bigger"}], "minimum": "2025-01-02T06:47:46", "maximum": "2025-12-30T19:27:11"}, {"@type": "Column", "name": "favourite_number", "datatype": "integer", "required": true, "privacyId": false, "nullableProportion": 0.0, "rowDependencies": [{"dependsOn": "timestamp_with_time", "dependencyType": "fixedPerEntity"}], "minimum": 0, "maximum": 5, "keyValues": [0, 1, 2, 3, 4, 5], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 6}]}} \ No newline at end of file diff --git a/csvw-safe-library/examples/penguin_plus.csv b/csvw-eo-library/examples/penguin_plus.csv similarity index 100% rename from csvw-safe-library/examples/penguin_plus.csv rename to csvw-eo-library/examples/penguin_plus.csv diff --git a/csvw-safe-library/examples/utils.py b/csvw-eo-library/examples/utils.py similarity index 100% rename from csvw-safe-library/examples/utils.py rename to csvw-eo-library/examples/utils.py diff --git a/csvw-safe-library/images/csvwsafe_workflow_1.png b/csvw-eo-library/images/csvwsafe_workflow_1.png similarity index 100% rename from csvw-safe-library/images/csvwsafe_workflow_1.png rename to csvw-eo-library/images/csvwsafe_workflow_1.png diff --git a/csvw-safe-library/images/csvwsafe_workflow_2.png b/csvw-eo-library/images/csvwsafe_workflow_2.png similarity index 100% rename from csvw-safe-library/images/csvwsafe_workflow_2.png rename to csvw-eo-library/images/csvwsafe_workflow_2.png diff --git a/csvw-safe-library/pyproject.toml b/csvw-eo-library/pyproject.toml similarity index 92% rename from csvw-safe-library/pyproject.toml rename to csvw-eo-library/pyproject.toml index 46c1509..faed125 100644 --- a/csvw-safe-library/pyproject.toml +++ b/csvw-eo-library/pyproject.toml @@ -1,5 +1,5 @@ [project] -name = "csvw-safe" +name = "csvw-eo" version = "0.1.0" description = "Safe processing utilities for CSVW data" readme = "README.md" @@ -7,7 +7,7 @@ requires-python = ">=3.9" authors = [ { name = "DSCC, FSO", email = "dscc@example.com" } ] -urls = { Homepage = "https://github.com/dsccadminch/csvw-safe-library/csvw-safe" } +urls = { Homepage = "https://github.com/dsccadminch/csvw-eo-library/csvw-eo" } classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", @@ -80,7 +80,7 @@ ignore = [ [tool.coverage.run] branch = true relative_files = true -source = ["csvw_safe"] # only track your package +source = ["csvw_eo"] # only track your package omit = [ "*/tests/*", # ignore test files ] diff --git a/csvw-safe-library/run_linter.sh b/csvw-eo-library/run_linter.sh similarity index 100% rename from csvw-safe-library/run_linter.sh rename to csvw-eo-library/run_linter.sh diff --git a/csvw-safe-library/src/csvw_safe/__init__.py b/csvw-eo-library/src/csvw_eo/__init__.py similarity index 97% rename from csvw-safe-library/src/csvw_safe/__init__.py rename to csvw-eo-library/src/csvw_eo/__init__.py index f342fac..cfd604c 100644 --- a/csvw-safe-library/src/csvw_safe/__init__.py +++ b/csvw-eo-library/src/csvw_eo/__init__.py @@ -1,5 +1,5 @@ """ -Top-level public interface for csvw_safe. +Top-level public interface for csvw_eo. This module provides a simplified API by re-exporting the most commonly used functions, classes, and constants for working with CSVW-style metadata. diff --git a/csvw-safe-library/src/csvw_safe/assert_same_structure.py b/csvw-eo-library/src/csvw_eo/assert_same_structure.py similarity index 96% rename from csvw-safe-library/src/csvw_safe/assert_same_structure.py rename to csvw-eo-library/src/csvw_eo/assert_same_structure.py index a1e5320..2b115f3 100644 --- a/csvw-safe-library/src/csvw_safe/assert_same_structure.py +++ b/csvw-eo-library/src/csvw_eo/assert_same_structure.py @@ -5,7 +5,7 @@ The script checks: - column names and order -- inferred CSVW-SAFE datatypes +- inferred CSVW-EO datatypes - nullability (required vs optional columns) - optional categorical value compatibility @@ -18,7 +18,7 @@ import pandas as pd -from csvw_safe.datatypes import ( +from csvw_eo.datatypes import ( XSD_GROUP_MAP, DataTypesGroups, infer_xmlschema_datatype, @@ -101,7 +101,7 @@ def assert_same_structure( def main() -> None: """Command-line entry point for the CSV structure validator.""" parser = argparse.ArgumentParser( - description="Assert that two CSV files match CSVW-SAFE structural properties" + description="Assert that two CSV files match CSVW-EO structural properties" ) parser.add_argument("original_csv", type=str, help="Original CSV file") parser.add_argument("dummy_csv", type=str, help="Dummy CSV file") diff --git a/csvw-safe-library/src/csvw_safe/constants.py b/csvw-eo-library/src/csvw_eo/constants.py similarity index 95% rename from csvw-safe-library/src/csvw_safe/constants.py rename to csvw-eo-library/src/csvw_eo/constants.py index f10459d..6a89a14 100644 --- a/csvw-safe-library/src/csvw_safe/constants.py +++ b/csvw-eo-library/src/csvw_eo/constants.py @@ -1,4 +1,4 @@ -"""Defaults, constants and metadata objects for csvw-safe.""" +"""Defaults, constants and metadata objects for csvw-eo.""" import string from enum import StrEnum @@ -21,7 +21,7 @@ # ============================================================ # CSVW_SAFE Namespaces # ============================================================ -CSVW_SAFE_CONTEXT = str((Path(__file__).resolve().parents[2] / "csvw-safe-context.jsonld").resolve()) # tmp +CSVW_SAFE_CONTEXT = str((Path(__file__).resolve().parents[2] / "csvw-eo-context.jsonld").resolve()) # tmp # Column groups / partitions COLUMN_GROUP = "ColumnGroup" diff --git a/csvw-safe-library/src/csvw_safe/csvw_to_opendp_context.py b/csvw-eo-library/src/csvw_eo/csvw_to_opendp_context.py similarity index 89% rename from csvw-safe-library/src/csvw_safe/csvw_to_opendp_context.py rename to csvw-eo-library/src/csvw_eo/csvw_to_opendp_context.py index 21bab78..366efdb 100644 --- a/csvw-safe-library/src/csvw_safe/csvw_to_opendp_context.py +++ b/csvw-eo-library/src/csvw_eo/csvw_to_opendp_context.py @@ -1,8 +1,8 @@ """ -Create an OpenDP Context from CSVW-SAFE metadata and a dataset. +Create an OpenDP Context from CSVW-EO metadata and a dataset. This module: -- Converts CSVW-SAFE metadata into OpenDP margins +- Converts CSVW-EO metadata into OpenDP margins - Builds an OpenDP Context using a provided dataset - Supports epsilon-based (Laplace) and rho-based (Gaussian) DP - Exposes both a Python API and CLI @@ -18,8 +18,8 @@ from opendp.extras.polars import Bound from opendp.mod import Measure, Metric, enable_features -from csvw_safe.constants import MAX_CONTRIB # , PRIVACY_UNIT -from csvw_safe.csvw_to_opendp_margins import csvw_to_opendp_margins +from csvw_eo.constants import MAX_CONTRIB # , PRIVACY_UNIT +from csvw_eo.csvw_to_opendp_margins import csvw_to_opendp_margins enable_features("contrib") @@ -68,12 +68,12 @@ def get_privacy_unit( csvw_meta: dict[str, Any], distance: str ) -> tuple[Metric, Union[float, Sequence[Bound]]]: """ - Construct an OpenDP privacy unit from CSVW-SAFE metadata. + Construct an OpenDP privacy unit from CSVW-EO metadata. Parameters ---------- csvw_meta : Dict[str, Any] - CSVW-SAFE metadata dictionary. + CSVW-EO metadata dictionary. distance : str Type of privacy distance metric to use (e.g. "contributions", "changes"). @@ -122,13 +122,13 @@ def csvw_to_opendp_context( # noqa: PLR0913 distance: str = "contributions", ) -> dp.Context: """ - Create an OpenDP Context from CSVW-SAFE metadata and a dataset. + Create an OpenDP Context from CSVW-EO metadata and a dataset. Parameters ---------- csvw_meta : Dict[str, Any] - CSVW-SAFE metadata dictionary. - Must include `csvw-safe.dp.maxContributions`. + CSVW-EO metadata dictionary. + Must include `csvw-eo.dp.maxContributions`. data : pl.LazyFrame Input dataset (recommended as LazyFrame). epsilon : float, optional diff --git a/csvw-safe-library/src/csvw_safe/csvw_to_opendp_margins.py b/csvw-eo-library/src/csvw_eo/csvw_to_opendp_margins.py similarity index 92% rename from csvw-safe-library/src/csvw_safe/csvw_to_opendp_margins.py rename to csvw-eo-library/src/csvw_eo/csvw_to_opendp_margins.py index 47feebc..be072a2 100644 --- a/csvw-safe-library/src/csvw_safe/csvw_to_opendp_margins.py +++ b/csvw-eo-library/src/csvw_eo/csvw_to_opendp_margins.py @@ -1,8 +1,8 @@ """ -Convert CSVW-SAFE JSON metadata into OpenDP margin descriptors. +Convert CSVW-EO JSON metadata into OpenDP margin descriptors. This module provides: -- A function to translate CSVW-SAFE differential privacy metadata into +- A function to translate CSVW-EO differential privacy metadata into OpenDP `dp.polars.Margin` objects. - A CLI for generating margin specifications from a JSON metadata file. @@ -20,7 +20,7 @@ from opendp.extras.polars import Margin -from csvw_safe.constants import ( +from csvw_eo.constants import ( ADD_INFO, COL_LIST, COL_NAME, @@ -77,12 +77,12 @@ def get_margins(col_meta: dict[str, Any], by: list[str]) -> dict[str, Any]: def csvw_to_opendp_margins(csvw_meta: dict[str, Any]) -> list["Margin"]: """ - Convert CSVW-SAFE metadata to a list of OpenDP Margin objects. + Convert CSVW-EO metadata to a list of OpenDP Margin objects. Parameters ---------- csvw_meta : Dict[str, Any] - CSVW-SAFE metadata dictionary. + CSVW-EO metadata dictionary. Returns ------- diff --git a/csvw-safe-library/src/csvw_safe/csvw_to_smartnoise_sql.py b/csvw-eo-library/src/csvw_eo/csvw_to_smartnoise_sql.py similarity index 92% rename from csvw-safe-library/src/csvw_safe/csvw_to_smartnoise_sql.py rename to csvw-eo-library/src/csvw_eo/csvw_to_smartnoise_sql.py index f5133fd..6eb0760 100644 --- a/csvw-safe-library/src/csvw_safe/csvw_to_smartnoise_sql.py +++ b/csvw-eo-library/src/csvw_eo/csvw_to_smartnoise_sql.py @@ -1,5 +1,5 @@ """ -Convert CSVW-SAFE JSON metadata to SmartNoise SQL metadata format. +Convert CSVW-EO JSON metadata to SmartNoise SQL metadata format. See smarntoise-sql documentation: https://docs.smartnoise.org/sql/metadata.html """ @@ -10,7 +10,7 @@ import yaml -from csvw_safe.constants import ( +from csvw_eo.constants import ( COL_LIST, COL_NAME, DATATYPE, @@ -23,7 +23,7 @@ REQUIRED, TABLE_SCHEMA, ) -from csvw_safe.datatypes import XSD_GROUP_MAP, DataTypesGroups, to_snsql_datatype +from csvw_eo.datatypes import XSD_GROUP_MAP, DataTypesGroups, to_snsql_datatype def csvw_to_snsql_column(col_meta: dict[str, Any]) -> dict[str, Any]: @@ -82,12 +82,12 @@ def csvw_to_smartnoise_sql( # noqa: PLR0913 use_dpsu: bool | None = None, ) -> dict[str, Any]: """ - Convert a CSVW-SAFE table metadata dictionary to SmartNoise SQL metadata. + Convert a CSVW-EO table metadata dictionary to SmartNoise SQL metadata. Parameters ---------- csvw_meta : Dict[str, Any] - The CSVW-SAFE metadata dictionary for a single table. + The CSVW-EO metadata dictionary for a single table. Must include "columns" list and "max_contributions" (used as max_ids). schema_name : str, default="" Name of the SmartNoise schema (top-level namespace) for the table. @@ -180,9 +180,9 @@ def csvw_to_smartnoise_sql( # noqa: PLR0913 def main() -> None: """ - CLI for converting CSVW-SAFE JSON metadata to SmartNoise SQL YAML metadata. + CLI for converting CSVW-EO JSON metadata to SmartNoise SQL YAML metadata. - This function reads a CSVW-SAFE JSON metadata file and converts it into SmartNoise SQL + This function reads a CSVW-EO JSON metadata file and converts it into SmartNoise SQL YAML metadata. All table-level options are configurable via CLI arguments, except `max_ids`, which must be present in the CSVW metadata (as 'max_contributions'). @@ -191,7 +191,7 @@ def main() -> None: Command-line arguments ---------------------- --input : str (required) - Path to input CSVW-SAFE JSON metadata file. + Path to input CSVW-EO JSON metadata file. --output : str (required) Path to output SmartNoise YAML metadata file. --schema : str (default="MySchema") @@ -210,9 +210,9 @@ def main() -> None: Use Differential Private Set Union for rare dimensions. """ parser = argparse.ArgumentParser( - description="Convert CSVW-SAFE JSON metadata to SmartNoise SQL YAML metadata." + description="Convert CSVW-EO JSON metadata to SmartNoise SQL YAML metadata." ) - parser.add_argument("--input", required=True, help="Input CSVW-SAFE JSON metadata file") + parser.add_argument("--input", required=True, help="Input CSVW-EO JSON metadata file") parser.add_argument("--output", required=True, help="Output SmartNoise YAML metadata file") parser.add_argument("--schema", default="MySchema", help="SmartNoise SQL schema name") parser.add_argument("--table", default="MyTable", help="SmartNoise SQL table name") diff --git a/csvw-safe-library/src/csvw_safe/datatypes.py b/csvw-eo-library/src/csvw_eo/datatypes.py similarity index 98% rename from csvw-safe-library/src/csvw_safe/datatypes.py rename to csvw-eo-library/src/csvw_eo/datatypes.py index d88dfd5..edc79f7 100644 --- a/csvw-safe-library/src/csvw_safe/datatypes.py +++ b/csvw-eo-library/src/csvw_eo/datatypes.py @@ -1,4 +1,4 @@ -"""CSVW-SAFE DataTypes Utilities.""" +"""CSVW-EO DataTypes Utilities.""" from datetime import datetime from enum import StrEnum @@ -6,7 +6,7 @@ import pandas as pd -from csvw_safe.constants import DATE_LENGTH +from csvw_eo.constants import DATE_LENGTH class ColumnKind(StrEnum): diff --git a/csvw-safe-library/src/csvw_safe/generate_series.py b/csvw-eo-library/src/csvw_eo/generate_series.py similarity index 97% rename from csvw-safe-library/src/csvw_safe/generate_series.py rename to csvw-eo-library/src/csvw_eo/generate_series.py index b3e5a72..6a37979 100644 --- a/csvw-safe-library/src/csvw_safe/generate_series.py +++ b/csvw-eo-library/src/csvw_eo/generate_series.py @@ -1,7 +1,7 @@ """ -CSVW-SAFE Dummy Dataset Generator. +CSVW-EO Dummy Dataset Generator. -This module generates a synthetic dummy dataset from CSVW-SAFE metadata. +This module generates a synthetic dummy dataset from CSVW-EO metadata. It is intended for testing pipelines and validating metadata structures. The generator supports: @@ -12,7 +12,7 @@ - column groups (joint partitions) The resulting dataset respects the structural information contained in -CSVW-SAFE metadata but does not guarantee semantic correctness. +CSVW-EO metadata but does not guarantee semantic correctness. """ from typing import Any @@ -20,7 +20,7 @@ import numpy as np import pandas as pd -from csvw_safe.constants import ( +from csvw_eo.constants import ( COL_NAME, DATATYPE, DEFAULT_NUMBER_PARTITIONS, @@ -40,7 +40,7 @@ VALUE_MAP, DependencyType, ) -from csvw_safe.datatypes import ( +from csvw_eo.datatypes import ( XSD_GROUP_MAP, DataTypes, DataTypesGroups, diff --git a/csvw-safe-library/src/csvw_safe/make_dummy_from_metadata.py b/csvw-eo-library/src/csvw_eo/make_dummy_from_metadata.py similarity index 94% rename from csvw-safe-library/src/csvw_safe/make_dummy_from_metadata.py rename to csvw-eo-library/src/csvw_eo/make_dummy_from_metadata.py index 5077d0e..d3ddd2e 100644 --- a/csvw-safe-library/src/csvw_safe/make_dummy_from_metadata.py +++ b/csvw-eo-library/src/csvw_eo/make_dummy_from_metadata.py @@ -1,7 +1,7 @@ """ -CSVW-SAFE Dummy Dataset Generator. +CSVW-EO Dummy Dataset Generator. -This module generates a synthetic dummy dataset from CSVW-SAFE metadata. +This module generates a synthetic dummy dataset from CSVW-EO metadata. It is intended for testing pipelines and validating metadata structures. The generator supports: @@ -12,7 +12,7 @@ - column groups (joint partitions) The resulting dataset respects the structural information contained in -CSVW-SAFE metadata but does not guarantee semantic correctness. +CSVW-EO metadata but does not guarantee semantic correctness. """ import argparse @@ -24,7 +24,7 @@ import numpy as np import pandas as pd -from csvw_safe.constants import ( +from csvw_eo.constants import ( ADD_INFO, COL_LIST, COL_NAME, @@ -42,8 +42,8 @@ TABLE_SCHEMA, UPPER_BOUND, ) -from csvw_safe.datatypes import XSD_GROUP_MAP, DataTypes, DataTypesGroups -from csvw_safe.generate_series import generate_dataframe +from csvw_eo.datatypes import XSD_GROUP_MAP, DataTypes, DataTypesGroups +from csvw_eo.generate_series import generate_dataframe RANDOM_STRINGS = list(string.ascii_lowercase + string.ascii_uppercase + string.digits) @@ -238,12 +238,12 @@ def make_dummy_from_metadata( seed: int = 0, ) -> pd.DataFrame: """ - Generate a dummy dataset from CSVW-SAFE metadata, respecting exhaustive column group partitions. + Generate a dummy dataset from CSVW-EO metadata, respecting exhaustive column group partitions. Parameters ---------- metadata : dict - CSVW-SAFE metadata structure. + CSVW-EO metadata structure. nb_rows : int, default=100 Number of rows to generate. seed : int, default=0 @@ -298,7 +298,7 @@ def make_dummy_from_metadata( def main() -> None: """Command-line interface for dummy dataset generation.""" - parser = argparse.ArgumentParser(description="Generate a dummy dataset from CSVW-SAFE metadata.") + parser = argparse.ArgumentParser(description="Generate a dummy dataset from CSVW-EO metadata.") parser.add_argument("metadata_file", type=str) parser.add_argument("--rows", type=int, default=100) diff --git a/csvw-safe-library/src/csvw_safe/make_metadata_from_data.py b/csvw-eo-library/src/csvw_eo/make_metadata_from_data.py similarity index 94% rename from csvw-safe-library/src/csvw_safe/make_metadata_from_data.py rename to csvw-eo-library/src/csvw_eo/make_metadata_from_data.py index 356737d..70d2be2 100644 --- a/csvw-safe-library/src/csvw_safe/make_metadata_from_data.py +++ b/csvw-eo-library/src/csvw_eo/make_metadata_from_data.py @@ -1,12 +1,12 @@ """ -CSVW-SAFE Metadata Generator. +CSVW-EO Metadata Generator. -This module generates CSVW-SAFE metadata from a CSV dataset. It automatically +This module generates CSVW-EO metadata from a CSV dataset. It automatically infers column datatypes, detects dependencies, builds partitions for categorical and numeric attributes, and computes contribution bounds relative to a defined privacy unit. -The output metadata follows the CSVW and CSVW-SAFE conventions used for +The output metadata follows the CSVW and CSVW-EO conventions used for privacy-preserving data synthesis and differential privacy pipelines. """ @@ -18,8 +18,8 @@ import pandas as pd from pandas.api.types import is_datetime64_any_dtype -from csvw_safe.constants import DependencyType -from csvw_safe.datatypes import ( +from csvw_eo.constants import DependencyType +from csvw_eo.datatypes import ( ColumnKind, DataTypes, T, @@ -27,7 +27,7 @@ is_categorical, is_continuous, ) -from csvw_safe.metadata_structure import ( +from csvw_eo.metadata_structure import ( CategoricalPredicate, ColumnGroupMetadata, ColumnMetadata, @@ -41,7 +41,7 @@ full_partition_to_key_multi, full_partition_to_key_single, ) -from csvw_safe.utils import ( +from csvw_eo.utils import ( ContributionLevel, get_effective_contrib_level, get_group_contribution_level, @@ -258,10 +258,10 @@ def build_partitions( column_specs: list[dict[str, Any]], ) -> list[Partition]: """ - Build CSVW-SAFE partitions and compute contribution bounds per partition. + Build CSVW-EO partitions and compute contribution bounds per partition. This function groups the dataset according to the provided column - specifications and calculates metadata required by CSVW-SAFE, including + specifications and calculates metadata required by CSVW-EO, including maximum partition size and per-privacy-unit contribution bounds. Numeric columns are first discretized into bins before grouping. @@ -293,13 +293,13 @@ def build_partitions( Returns ------- list of dict - A list of CSVW-SAFE partition metadata objects. Each entry contains: + A list of CSVW-EO partition metadata objects. Each entry contains: - "@type": Partition type - - "csvw-safe:predicate": partition condition - - "csvw-safe:bounds.maxLength": maximum rows in partition - - "csvw-safe:bounds.maxGroupsPerUnit": maximum rows per privacy unit - - "csvw-safe:bounds.maxContributions": maximum partitions per unit + - "csvw-eo:predicate": partition condition + - "csvw-eo:bounds.maxLength": maximum rows in partition + - "csvw-eo:bounds.maxGroupsPerUnit": maximum rows per privacy unit + - "csvw-eo:bounds.maxContributions": maximum partitions per unit """ df_work = df.copy() if any(spec["kind"] == ColumnKind.CONTINUOUS for spec in column_specs) else df @@ -390,7 +390,7 @@ def make_column_groups( # noqa: PLR0913 privacy_unit: str, ) -> list[ColumnGroupMetadata]: """ - Build CSVW-SAFE metadata for column groups. + Build CSVW-EO metadata for column groups. A column group represents a set of columns that should be treated jointly when defining contribution bounds and partitions. Partitions are computed @@ -423,7 +423,7 @@ def make_column_groups( # noqa: PLR0913 Returns ------- list[dict[str, Any]] - A list of CSVW-SAFE column group metadata dictionaries including + A list of CSVW-EO column group metadata dictionaries including partition definitions and contribution bounds. """ @@ -555,7 +555,7 @@ def build_column_metadata( # noqa: PLR0913 Construct metadata for a single column. This function infers column properties and computes metadata fields - required by CSVW-SAFE, including datatype inference, nullability, + required by CSVW-EO, including datatype inference, nullability, dependencies, fixed-per-entity attributes, and optional contribution partitions. @@ -590,7 +590,7 @@ def build_column_metadata( # noqa: PLR0913 Returns ------- ColumnMetadata - Metadata object describing the column according to the CSVW-SAFE + Metadata object describing the column according to the CSVW-EO specification. """ @@ -641,7 +641,7 @@ def make_metadata_from_data( # noqa: PLR0913 fine_contributions_level: dict[str, str] | None = None, ) -> dict[str, Any]: """ - Generate CSVW-SAFE metadata from a dataset and return JSON-serializable dictionary. + Generate CSVW-EO metadata from a dataset and return JSON-serializable dictionary. Parameters ---------- @@ -663,7 +663,7 @@ def make_metadata_from_data( # noqa: PLR0913 Returns ------- TableMetadata - CSVW-SAFE metadata structure as a dataclass. + CSVW-EO metadata structure as a dataclass. """ default_level, fine_level, continuous_partitions, column_groups = prepare_metadata_inputs( @@ -729,11 +729,11 @@ def make_metadata_from_data( # noqa: PLR0913 # ============================================================ def main() -> None: """ - Command-line entry point for generating CSVW-SAFE metadata. + Command-line entry point for generating CSVW-EO metadata. This function parses command-line arguments, loads the input CSV dataset, performs basic datatype inference (including datetime detection), and - generates CSVW-SAFE metadata describing the dataset structure, privacy + generates CSVW-EO metadata describing the dataset structure, privacy unit, contribution bounds, and optional partitions. The resulting metadata is written as a JSON file. @@ -769,11 +769,11 @@ def main() -> None: Datetime inference is attempted automatically for all columns by attempting to parse values using ``pandas.to_datetime``. - The generated metadata conforms to the CSVW-SAFE specification and + The generated metadata conforms to the CSVW-EO specification and can be used by downstream privacy-preserving data synthesis systems. """ - parser = argparse.ArgumentParser(description="Generate CSVW-SAFE metadata from a CSV dataset.") + parser = argparse.ArgumentParser(description="Generate CSVW-EO metadata from a CSV dataset.") parser.add_argument("csv_file", help="Path to input CSV file") @@ -828,7 +828,7 @@ def main() -> None: with open(args.output, "w", encoding="utf-8") as f: json.dump(metadata, f, indent=2) - print(f"CSVW-SAFE metadata written to {args.output}") # noqa: T201 + print(f"CSVW-EO metadata written to {args.output}") # noqa: T201 if __name__ == "__main__": diff --git a/csvw-safe-library/src/csvw_safe/metadata_structure.py b/csvw-eo-library/src/csvw_eo/metadata_structure.py similarity index 93% rename from csvw-safe-library/src/csvw_safe/metadata_structure.py rename to csvw-eo-library/src/csvw_eo/metadata_structure.py index 02350e1..132cfad 100644 --- a/csvw-safe-library/src/csvw_safe/metadata_structure.py +++ b/csvw-eo-library/src/csvw_eo/metadata_structure.py @@ -1,11 +1,11 @@ -"""Pydantic models for CSVW-SAFE metadata structure.""" +"""Pydantic models for CSVW-EO metadata structure.""" from typing import Any, Union from pydantic import BaseModel, Field -from csvw_safe import constants as c -from csvw_safe.datatypes import DataTypes +from csvw_eo import constants as c +from csvw_eo.datatypes import DataTypes class Dependency(BaseModel): @@ -21,7 +21,7 @@ class Dependency(BaseModel): value_map: dict[Any, Any] | None = None def to_dict(self) -> dict[str, Any]: - """Convert the dependency to a CSVW-SAFE compliant dictionary.""" + """Convert the dependency to a CSVW-EO compliant dictionary.""" d: dict[str, Any] = { c.DEPENDS_ON: self.depends_on, c.DEPENDENCY_TYPE: self.dependency_type, @@ -34,7 +34,7 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls, data: dict[str, Any]) -> "Dependency": - """Create a Dependency instance from CSVW-SAFE metadata.""" + """Create a Dependency instance from CSVW-EO metadata.""" return cls( depends_on=data[c.DEPENDS_ON], dependency_type=data[c.DEPENDENCY_TYPE], @@ -48,12 +48,12 @@ class CategoricalPredicate(BaseModel): partition_value: Any | None def to_dict(self) -> dict[str, Any]: - """Convert the predicate into CSVW-SAFE JSON format.""" + """Convert the predicate into CSVW-EO JSON format.""" return {c.PARTITION_VALUE: self.partition_value} @classmethod def from_dict(cls, data: dict[str, Any]) -> "CategoricalPredicate": - """Create a Predicate from CSVW-SAFE metadata.""" + """Create a Predicate from CSVW-EO metadata.""" return cls(partition_value=data[c.PARTITION_VALUE]) @@ -64,7 +64,7 @@ class ContinuousPredicate(BaseModel): upper_bound: float | str | None def to_dict(self) -> dict[str, Any]: - """Convert the predicate into CSVW-SAFE JSON format.""" + """Convert the predicate into CSVW-EO JSON format.""" return { c.LOWER_BOUND: self.lower_bound, c.UPPER_BOUND: self.upper_bound, @@ -72,7 +72,7 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls, data: dict[str, Any]) -> "ContinuousPredicate": - """Create a Predicate from CSVW-SAFE metadata.""" + """Create a Predicate from CSVW-EO metadata.""" return cls( lower_bound=data[c.LOWER_BOUND], upper_bound=data[c.UPPER_BOUND], @@ -105,7 +105,7 @@ def _predicate_to_dict(self) -> dict[str, Any]: raise NotImplementedError def to_dict(self) -> dict[str, Any]: - """Convert the partition to CSVW-SAFE JSON format.""" + """Convert the partition to CSVW-EO JSON format.""" return { "@type": c.PARTITION, c.PREDICATE: self._predicate_to_dict(), @@ -174,7 +174,7 @@ class SingleColumnKey(BaseModel): def to_dict(self) -> Any: # noqa: ANN401 """ - Convert a categorical partition to CSVW-SAFE JSON format. + Convert a categorical partition to CSVW-EO JSON format. Returns: The partition value (e.g., 'blue'). @@ -210,12 +210,12 @@ class MultiColumnKeys(BaseModel): predicate: dict[str, Predicate] def to_dict(self) -> dict[str, Any]: - """Convert the partition to CSVW-SAFE JSON format.""" + """Convert the partition to CSVW-EO JSON format.""" return {k: v.to_dict() for k, v in self.predicate.items()} @classmethod def from_dict(cls, data: dict[str, Any]) -> "MultiColumnKeys": - """Create a MultiColumnKeys from CSVW-SAFE metadata.""" + """Create a MultiColumnKeys from CSVW-EO metadata.""" predicates = {k: parse_predicate(v) for k, v in data.items()} return cls(predicate=predicates) @@ -271,7 +271,7 @@ class ColumnMetadata(BaseModel): max_num_partitions: int | None = None def to_dict(self) -> dict[str, Any]: # noqa: PLR0912 - """Convert the column metadata to CSVW-SAFE JSON format.""" + """Convert the column metadata to CSVW-EO JSON format.""" d: dict[str, Any] = { "@type": c.COL_TYPE, c.COL_NAME: self.name, @@ -330,7 +330,7 @@ def to_dict(self) -> dict[str, Any]: # noqa: PLR0912 @classmethod def from_dict(cls, data: dict[str, Any]) -> "ColumnMetadata": """ - Parse column metadata from CSVW-SAFE JSON. + Parse column metadata from CSVW-EO JSON. Parameters ---------- @@ -456,7 +456,7 @@ def from_dict(cls, data: dict[str, Any]) -> "ColumnGroupMetadata": class TableMetadata(BaseModel): - """Top-level metadata object describing a CSVW-SAFE table.""" + """Top-level metadata object describing a CSVW-EO table.""" privacy_unit: str | None = None max_contributions: int | None = None @@ -471,7 +471,7 @@ class TableMetadata(BaseModel): table_type: str = c.TABLE_TYPE def to_dict(self) -> dict[str, Any]: - """Serialize the full metadata object to CSVW-SAFE JSON.""" + """Serialize the full metadata object to CSVW-EO JSON.""" d: dict[str, Any] = { "@context": self.context, "@type": self.table_type, @@ -490,7 +490,7 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls, data: dict[str, Any]) -> "TableMetadata": """ - Parse a CSVW-SAFE metadata document. + Parse a CSVW-EO metadata document. Parameters ---------- diff --git a/csvw-safe-library/src/csvw_safe/utils.py b/csvw-eo-library/src/csvw_eo/utils.py similarity index 98% rename from csvw-safe-library/src/csvw_safe/utils.py rename to csvw-eo-library/src/csvw_eo/utils.py index 667d336..f4eb5d8 100644 --- a/csvw-safe-library/src/csvw_safe/utils.py +++ b/csvw-eo-library/src/csvw_eo/utils.py @@ -9,7 +9,7 @@ def sanitize(obj: dict[str, Any]) -> dict[str, Any]: """ - Recursively convert objects into JSON/CSVW-SAFE serializable types. + Recursively convert objects into JSON/CSVW-EO serializable types. - NumPy scalars → Python scalars - NaN or Inf → None @@ -32,7 +32,7 @@ def sanitize(obj: dict[str, Any]) -> dict[str, Any]: class ContributionLevel(IntEnum): """ - Represents the level at which contribution bounds are applied in CSVW-SAFE metadata. + Represents the level at which contribution bounds are applied in CSVW-EO metadata. Levels: - TABLE: global table-level contribution bounds diff --git a/csvw-safe-library/src/csvw_safe/validate_metadata.py b/csvw-eo-library/src/csvw_eo/validate_metadata.py similarity index 81% rename from csvw-safe-library/src/csvw_safe/validate_metadata.py rename to csvw-eo-library/src/csvw_eo/validate_metadata.py index 15be830..b696c33 100644 --- a/csvw-safe-library/src/csvw_safe/validate_metadata.py +++ b/csvw-eo-library/src/csvw_eo/validate_metadata.py @@ -5,17 +5,17 @@ from pathlib import Path from typing import Any -from csvw_safe.metadata_structure import TableMetadata +from csvw_eo.metadata_structure import TableMetadata def validate_metadata(metadata: dict[str, Any]) -> TableMetadata: """ - Validate CSVW-SAFE metadata against the pydantic model. + Validate CSVW-EO metadata against the pydantic model. Parameters ---------- metadata : dict - CSVW-SAFE metadata structure. + CSVW-EO metadata structure. """ return TableMetadata.from_dict(metadata) @@ -23,7 +23,7 @@ def validate_metadata(metadata: dict[str, Any]) -> TableMetadata: def main() -> None: """ - Command-line interface for SHACL validation of CSVW-SAFE metadata. + Command-line interface for SHACL validation of CSVW-EO metadata. This function parses command-line arguments specifying the metadata JSON-LD file and the SHACL shapes file, then runs SHACL validation. @@ -32,7 +32,7 @@ def main() -> None: fails, the validation report is printed and the program exits with a non-zero status code. """ - parser = argparse.ArgumentParser(description="SHACL validation for CSVW-SAFE metadata") + parser = argparse.ArgumentParser(description="SHACL validation for CSVW-EO metadata") parser.add_argument("metadata_file", type=str) args = parser.parse_args() diff --git a/csvw-safe-library/src/csvw_safe/validate_metadata_shacl.py b/csvw-eo-library/src/csvw_eo/validate_metadata_shacl.py similarity index 90% rename from csvw-safe-library/src/csvw_safe/validate_metadata_shacl.py rename to csvw-eo-library/src/csvw_eo/validate_metadata_shacl.py index c6188b8..2a0eeea 100644 --- a/csvw-safe-library/src/csvw_safe/validate_metadata_shacl.py +++ b/csvw-eo-library/src/csvw_eo/validate_metadata_shacl.py @@ -1,7 +1,7 @@ """ -SHACL validation for CSVW-SAFE metadata. +SHACL validation for CSVW-EO metadata. -This module validates CSVW-SAFE metadata files against a SHACL schema +This module validates CSVW-EO metadata files against a SHACL schema using the pySHACL engine. The metadata is expected to be in JSON-LD format and the SHACL shapes in Turtle format. @@ -21,7 +21,7 @@ def validate_metadata_shacl(metadata_file: Path, shacl_file: Path) -> tuple[bool, str]: """ - Validate CSVW-SAFE metadata against a SHACL schema. + Validate CSVW-EO metadata against a SHACL schema. Parameters ---------- @@ -58,7 +58,7 @@ def validate_metadata_shacl(metadata_file: Path, shacl_file: Path) -> tuple[bool def main() -> None: """ - Command-line interface for SHACL validation of CSVW-SAFE metadata. + Command-line interface for SHACL validation of CSVW-EO metadata. This function parses command-line arguments specifying the metadata JSON-LD file and the SHACL shapes file, then runs SHACL validation. @@ -67,7 +67,7 @@ def main() -> None: fails, the validation report is printed and the program exits with a non-zero status code. """ - parser = argparse.ArgumentParser(description="SHACL validation for CSVW-SAFE metadata") + parser = argparse.ArgumentParser(description="SHACL validation for CSVW-EO metadata") parser.add_argument("metadata_file", type=str) parser.add_argument("shacl_file", type=str, help="SHACL TTL file") args = parser.parse_args() diff --git a/csvw-safe-library/tests/test_csvw_to_opendp_context.py b/csvw-eo-library/tests/test_csvw_to_opendp_context.py similarity index 95% rename from csvw-safe-library/tests/test_csvw_to_opendp_context.py rename to csvw-eo-library/tests/test_csvw_to_opendp_context.py index a0c0f3b..1a3f160 100644 --- a/csvw-safe-library/tests/test_csvw_to_opendp_context.py +++ b/csvw-eo-library/tests/test_csvw_to_opendp_context.py @@ -2,7 +2,7 @@ import polars as pl import pytest -from csvw_safe.constants import ( # PRIVACY_ID, +from csvw_eo.constants import ( # PRIVACY_ID, ADD_INFO, COL_LIST, COL_NAME, @@ -14,14 +14,14 @@ PRIVACY_UNIT, TABLE_SCHEMA, ) -from csvw_safe.csvw_to_opendp_context import csvw_to_opendp_context +from csvw_eo.csvw_to_opendp_context import csvw_to_opendp_context dp.enable_features("contrib") @pytest.fixture def mock_csvw_meta(): - """Return a small CSVW-SAFE metadata dict for testing.""" + """Return a small CSVW-EO metadata dict for testing.""" return { MAX_CONTRIB: 3, TABLE_SCHEMA: { @@ -165,7 +165,7 @@ def test_changes_distance(mock_csvw_meta, mock_data): def test_column_group_context(mock_data): - """CSVW-SAFE metadata for margins testing.""" + """CSVW-EO metadata for margins testing.""" mock_csvw_meta = { MAX_CONTRIB: 10, MAX_LENGTH: 100, @@ -195,7 +195,7 @@ def test_column_group_context(mock_data): def test_column_group_context_not_invariant(mock_data): - """CSVW-SAFE metadata for margins testing.""" + """CSVW-EO metadata for margins testing.""" mock_csvw_meta = { MAX_CONTRIB: 10, MAX_LENGTH: 100, diff --git a/csvw-safe-library/tests/test_csvw_to_opendp_margins.py b/csvw-eo-library/tests/test_csvw_to_opendp_margins.py similarity index 94% rename from csvw-safe-library/tests/test_csvw_to_opendp_margins.py rename to csvw-eo-library/tests/test_csvw_to_opendp_margins.py index 957db60..d039c43 100644 --- a/csvw-safe-library/tests/test_csvw_to_opendp_margins.py +++ b/csvw-eo-library/tests/test_csvw_to_opendp_margins.py @@ -1,4 +1,4 @@ -from csvw_safe.constants import ( +from csvw_eo.constants import ( ADD_INFO, COL_LIST, COL_NAME, @@ -11,11 +11,11 @@ PUBLIC_LENGTH, TABLE_SCHEMA, ) -from csvw_safe.csvw_to_opendp_margins import csvw_to_opendp_margins +from csvw_eo.csvw_to_opendp_margins import csvw_to_opendp_margins def mock_csvw_metadata(): - """CSVW-SAFE metadata for margins testing.""" + """CSVW-EO metadata for margins testing.""" return { MAX_LENGTH: 1000, PUBLIC_LENGTH: 1000, @@ -115,7 +115,7 @@ def test_no_optional_fields(): def test_column_group(): - """CSVW-SAFE metadata for margins testing.""" + """CSVW-EO metadata for margins testing.""" csvw_meta = { MAX_CONTRIB: 10, TABLE_SCHEMA: {COL_LIST: [{COL_NAME: "col1"}]}, diff --git a/csvw-safe-library/tests/test_csvw_to_smartnoise_sql.py b/csvw-eo-library/tests/test_csvw_to_smartnoise_sql.py similarity index 96% rename from csvw-safe-library/tests/test_csvw_to_smartnoise_sql.py rename to csvw-eo-library/tests/test_csvw_to_smartnoise_sql.py index 5afda66..aae9152 100644 --- a/csvw-safe-library/tests/test_csvw_to_smartnoise_sql.py +++ b/csvw-eo-library/tests/test_csvw_to_smartnoise_sql.py @@ -1,7 +1,7 @@ import pytest import yaml -from csvw_safe.constants import ( +from csvw_eo.constants import ( COL_LIST, COL_NAME, DATATYPE, @@ -13,11 +13,11 @@ REQUIRED, TABLE_SCHEMA, ) -from csvw_safe.csvw_to_smartnoise_sql import csvw_to_smartnoise_sql +from csvw_eo.csvw_to_smartnoise_sql import csvw_to_smartnoise_sql def mock_csvw_metadata(): - """Return a small CSVW-SAFE JSON metadata for testing.""" + """Return a small CSVW-EO JSON metadata for testing.""" return { MAX_CONTRIB: 1, # required by csvw_to_smartnoise_sql TABLE_SCHEMA: { diff --git a/csvw-safe-library/tests/test_datatypes.py b/csvw-eo-library/tests/test_datatypes.py similarity index 99% rename from csvw-safe-library/tests/test_datatypes.py rename to csvw-eo-library/tests/test_datatypes.py index 299c471..61d97e4 100644 --- a/csvw-safe-library/tests/test_datatypes.py +++ b/csvw-eo-library/tests/test_datatypes.py @@ -2,7 +2,7 @@ import pandas as pd import pytest -from csvw_safe.datatypes import ( +from csvw_eo.datatypes import ( DataTypes, infer_xmlschema_datatype, is_categorical, diff --git a/csvw-safe-library/tests/test_generate_series.py b/csvw-eo-library/tests/test_generate_series.py similarity index 98% rename from csvw-safe-library/tests/test_generate_series.py rename to csvw-eo-library/tests/test_generate_series.py index 4625457..f561f07 100644 --- a/csvw-safe-library/tests/test_generate_series.py +++ b/csvw-eo-library/tests/test_generate_series.py @@ -2,7 +2,7 @@ import pandas as pd import pytest -from csvw_safe.constants import ( +from csvw_eo.constants import ( COL_NAME, DATATYPE, DEFAULT_NUMBER_PARTITIONS, @@ -23,8 +23,8 @@ VALUE_MAP, DependencyType, ) -from csvw_safe.datatypes import DataTypes -from csvw_safe.generate_series import ( +from csvw_eo.datatypes import DataTypes +from csvw_eo.generate_series import ( bigger_series, fixed_series, mapping_series, diff --git a/csvw-safe-library/tests/test_make_dummy.py b/csvw-eo-library/tests/test_make_dummy.py similarity index 97% rename from csvw-safe-library/tests/test_make_dummy.py rename to csvw-eo-library/tests/test_make_dummy.py index 5c8e6c0..a7de68c 100644 --- a/csvw-safe-library/tests/test_make_dummy.py +++ b/csvw-eo-library/tests/test_make_dummy.py @@ -2,7 +2,7 @@ import pandas as pd import pytest -from csvw_safe.constants import ( +from csvw_eo.constants import ( ADD_INFO, COL_LIST, COL_NAME, @@ -20,8 +20,8 @@ TABLE_SCHEMA, UPPER_BOUND, ) -from csvw_safe.datatypes import DataTypes -from csvw_safe.make_dummy_from_metadata import ( +from csvw_eo.datatypes import DataTypes +from csvw_eo.make_dummy_from_metadata import ( _apply_value_mask, _predicate_mask, apply_nulls_serie, diff --git a/csvw-safe-library/tests/test_make_metadata_contributions.py b/csvw-eo-library/tests/test_make_metadata_contributions.py similarity index 98% rename from csvw-safe-library/tests/test_make_metadata_contributions.py rename to csvw-eo-library/tests/test_make_metadata_contributions.py index 593ecd6..b4d3a11 100644 --- a/csvw-safe-library/tests/test_make_metadata_contributions.py +++ b/csvw-eo-library/tests/test_make_metadata_contributions.py @@ -1,13 +1,13 @@ import pandas as pd import pytest -from csvw_safe import constants as c -from csvw_safe.make_metadata_from_data import ( +from csvw_eo import constants as c +from csvw_eo.make_metadata_from_data import ( build_partitions, make_metadata_from_data, make_numeric_partitions, ) -from csvw_safe.metadata_structure import ( +from csvw_eo.metadata_structure import ( CategoricalPredicate, ContinuousPredicate, MultiColumnPartition, diff --git a/csvw-safe-library/tests/test_make_metadata_main.py b/csvw-eo-library/tests/test_make_metadata_main.py similarity index 98% rename from csvw-safe-library/tests/test_make_metadata_main.py rename to csvw-eo-library/tests/test_make_metadata_main.py index b22ea80..34bea5f 100644 --- a/csvw-safe-library/tests/test_make_metadata_main.py +++ b/csvw-eo-library/tests/test_make_metadata_main.py @@ -2,8 +2,8 @@ import pandas as pd import pytest -from csvw_safe import constants as c -from csvw_safe.make_metadata_from_data import make_metadata_from_data +from csvw_eo import constants as c +from csvw_eo.make_metadata_from_data import make_metadata_from_data @pytest.fixture diff --git a/csvw-safe-library/tests/test_make_metadata_synth.py b/csvw-eo-library/tests/test_make_metadata_synth.py similarity index 97% rename from csvw-safe-library/tests/test_make_metadata_synth.py rename to csvw-eo-library/tests/test_make_metadata_synth.py index 672b3c1..d6c23b4 100644 --- a/csvw-safe-library/tests/test_make_metadata_synth.py +++ b/csvw-eo-library/tests/test_make_metadata_synth.py @@ -1,7 +1,7 @@ import pandas as pd -from csvw_safe.constants import DependencyType -from csvw_safe.make_metadata_from_data import ( +from csvw_eo.constants import DependencyType +from csvw_eo.make_metadata_from_data import ( get_continuous_bounds, identify_dependency, ) diff --git a/csvw-safe-library/tests/test_penguin_dataset.py b/csvw-eo-library/tests/test_penguin_dataset.py similarity index 95% rename from csvw-safe-library/tests/test_penguin_dataset.py rename to csvw-eo-library/tests/test_penguin_dataset.py index 0d0f03d..03a42cd 100644 --- a/csvw-safe-library/tests/test_penguin_dataset.py +++ b/csvw-eo-library/tests/test_penguin_dataset.py @@ -4,11 +4,11 @@ # import pandas as pd # import pytest -# from csvw_safe.assert_same_structure import assert_same_structure -# from csvw_safe.make_dummy_from_metadata import make_dummy_from_metadata -# from csvw_safe.make_metadata_from_data import make_metadata_from_data -# from csvw_safe.validate_metadata import validate_metadata -# from csvw_safe.validate_metadata_shacl import validate_metadata_shacl +# from csvw_eo.assert_same_structure import assert_same_structure +# from csvw_eo.make_dummy_from_metadata import make_dummy_from_metadata +# from csvw_eo.make_metadata_from_data import make_metadata_from_data +# from csvw_eo.validate_metadata import validate_metadata +# from csvw_eo.validate_metadata_shacl import validate_metadata_shacl # def make_random_unique_id( @@ -134,7 +134,7 @@ # @pytest.fixture(scope="session") # def shacl_path(): -# return "../csvw-safe-constraints.ttl" +# return "../csvw-eo-constraints.ttl" # @pytest.fixture(scope="session") diff --git a/csvw-safe-library/tests/test_same_structure.py b/csvw-eo-library/tests/test_same_structure.py similarity index 97% rename from csvw-safe-library/tests/test_same_structure.py rename to csvw-eo-library/tests/test_same_structure.py index e45bc77..d88002e 100644 --- a/csvw-safe-library/tests/test_same_structure.py +++ b/csvw-eo-library/tests/test_same_structure.py @@ -1,7 +1,7 @@ import pandas as pd import pytest -from csvw_safe.assert_same_structure import assert_same_structure +from csvw_eo.assert_same_structure import assert_same_structure def test_assert_same_structure(): diff --git a/csvw-safe-library/tests/test_validate_metadata.py b/csvw-eo-library/tests/test_validate_metadata.py similarity index 98% rename from csvw-safe-library/tests/test_validate_metadata.py rename to csvw-eo-library/tests/test_validate_metadata.py index 99cdd34..f062474 100644 --- a/csvw-safe-library/tests/test_validate_metadata.py +++ b/csvw-eo-library/tests/test_validate_metadata.py @@ -1,7 +1,7 @@ -from csvw_safe import constants as c -from csvw_safe.constants import DependencyType -from csvw_safe.datatypes import DataTypes -from csvw_safe.metadata_structure import ( +from csvw_eo import constants as c +from csvw_eo.constants import DependencyType +from csvw_eo.datatypes import DataTypes +from csvw_eo.metadata_structure import ( ColumnMetadata, ContinuousPredicate, MultiColumnPartition, @@ -9,7 +9,7 @@ SingleColumnPartition, TableMetadata, ) -from csvw_safe.validate_metadata import validate_metadata +from csvw_eo.validate_metadata import validate_metadata def test_validate_metadata_minimal(): diff --git a/csvw-safe-library/tests/test_validate_metadata_shacl.py b/csvw-eo-library/tests/test_validate_metadata_shacl.py similarity index 83% rename from csvw-safe-library/tests/test_validate_metadata_shacl.py rename to csvw-eo-library/tests/test_validate_metadata_shacl.py index 5c3e4e1..e5fe44f 100644 --- a/csvw-safe-library/tests/test_validate_metadata_shacl.py +++ b/csvw-eo-library/tests/test_validate_metadata_shacl.py @@ -2,14 +2,14 @@ import pytest -from csvw_safe import constants as c -from csvw_safe.datatypes import DataTypes -from csvw_safe.validate_metadata_shacl import validate_metadata_shacl +from csvw_eo import constants as c +from csvw_eo.datatypes import DataTypes +from csvw_eo.validate_metadata_shacl import validate_metadata_shacl @pytest.fixture(scope="session") def shacl_path(): - return "../csvw-safe-constraints.ttl" + return "../csvw-eo-constraints.ttl" @pytest.fixture(scope="session") diff --git a/csvw-safe-vocab.ttl b/csvw-eo-vocab.ttl similarity index 60% rename from csvw-safe-vocab.ttl rename to csvw-eo-vocab.ttl index 1908a15..7cab90b 100644 --- a/csvw-safe-vocab.ttl +++ b/csvw-eo-vocab.ttl @@ -1,4 +1,4 @@ -@prefix csvw-safe: . +@prefix csvw-eo: . @prefix csvw: . @prefix rdf: . @prefix rdfs: . @@ -11,7 +11,7 @@ # Ontology # ===================================================== -csvw-safe: +csvw-eo: a owl:Ontology ; dct:title "CSVW Differential Privacy Extension Vocabulary" ; owl:versionInfo "0.3.0" ; @@ -32,20 +32,20 @@ csvw-safe: # Core Classes ################################################################################ -csvw-safe:GroupingKey a owl:Class ; +csvw-eo:GroupingKey a owl:Class ; rdfs:label "Grouping Key" ; rdfs:comment "Represents a multi-column grouping space." . -csvw-safe:ColumnGroup a owl:Class ; - rdfs:subClassOf csvw-safe:GroupingKey ; +csvw-eo:ColumnGroup a owl:Class ; + rdfs:subClassOf csvw-eo:GroupingKey ; rdfs:label "Column Group" ; rdfs:comment "Grouping key composed of multiple columns." . -csvw-safe:Partition a owl:Class ; +csvw-eo:Partition a owl:Class ; rdfs:label "Partition" ; rdfs:comment "A publicly defined region of the value domain." . -csvw-safe:Contribution a owl:Class ; +csvw-eo:Contribution a owl:Class ; rdfs:label "Contribution" ; rdfs:comment "Contribution bounds relative to a specific privacy unit." . @@ -53,74 +53,74 @@ csvw-safe:Contribution a owl:Class ; # Privacy Model ################################################################################ -csvw-safe:privacyModel a owl:ObjectProperty ; +csvw-eo:privacyModel a owl:ObjectProperty ; rdfs:domain csvw:Table ; - rdfs:range csvw-safe:PrivacyModel ; + rdfs:range csvw-eo:PrivacyModel ; rdfs:label "privacy model" . -csvw-safe:PrivacyModel a owl:Class . +csvw-eo:PrivacyModel a owl:Class . -csvw-safe:independent a csvw-safe:PrivacyModel . -csvw-safe:hierarchical a csvw-safe:PrivacyModel . -csvw-safe:joint a csvw-safe:PrivacyModel . +csvw-eo:independent a csvw-eo:PrivacyModel . +csvw-eo:hierarchical a csvw-eo:PrivacyModel . +csvw-eo:joint a csvw-eo:PrivacyModel . ################################################################################ # Public Invariant Properties ################################################################################ -csvw-safe:public.privacyUnit a owl:DatatypeProperty ; +csvw-eo:public.privacyUnit a owl:DatatypeProperty ; rdfs:domain [ a owl:Class ; - owl:unionOf (csvw:Table csvw-safe:Contribution) + owl:unionOf (csvw:Table csvw-eo:Contribution) ] ; rdfs:range xsd:string ; rdfs:label "privacy unit identifier" . -csvw-safe:public.privacyId a owl:DatatypeProperty ; +csvw-eo:public.privacyId a owl:DatatypeProperty ; rdfs:domain csvw:Column ; rdfs:range xsd:boolean . -csvw-safe:public.length a owl:DatatypeProperty ; +csvw-eo:public.length a owl:DatatypeProperty ; rdfs:domain [ a owl:Class ; - owl:unionOf (csvw:Table csvw-safe:Partition) + owl:unionOf (csvw:Table csvw-eo:Partition) ] ; rdfs:range xsd:nonNegativeInteger . -csvw-safe:public.maxNumPartitions a owl:DatatypeProperty ; - rdfs:domain csvw-safe:GroupingKey ; +csvw-eo:public.maxNumPartitions a owl:DatatypeProperty ; + rdfs:domain csvw-eo:GroupingKey ; rdfs:range xsd:nonNegativeInteger . -csvw-safe:public.partitions a owl:ObjectProperty ; - rdfs:domain csvw-safe:GroupingKey ; - rdfs:range csvw-safe:Partition . +csvw-eo:public.partitions a owl:ObjectProperty ; + rdfs:domain csvw-eo:GroupingKey ; + rdfs:range csvw-eo:Partition . -csvw-safe:public.exhaustivePartitions a owl:DatatypeProperty ; - rdfs:domain csvw-safe:GroupingKey ; +csvw-eo:public.exhaustivePartitions a owl:DatatypeProperty ; + rdfs:domain csvw-eo:GroupingKey ; rdfs:range xsd:boolean . ################################################################################ # Contribution Bounds (Privacy Guarantees) ################################################################################ -csvw-safe:bounds.maxContributions a owl:DatatypeProperty ; +csvw-eo:bounds.maxContributions a owl:DatatypeProperty ; rdfs:domain [ a owl:Class ; - owl:unionOf (csvw:Table csvw-safe:Partition csvw-safe:Contribution) + owl:unionOf (csvw:Table csvw-eo:Partition csvw-eo:Contribution) ] ; rdfs:range xsd:nonNegativeInteger ; rdfs:comment "l_infinity bound: max rows per privacy unit per region." . -csvw-safe:bounds.maxLength a owl:DatatypeProperty ; +csvw-eo:bounds.maxLength a owl:DatatypeProperty ; rdfs:domain [ a owl:Class ; - owl:unionOf (csvw:Table csvw-safe:Partition) + owl:unionOf (csvw:Table csvw-eo:Partition) ] ; rdfs:range xsd:nonNegativeInteger ; rdfs:comment "Maximum theoretical number of rows." . -csvw-safe:bounds.maxGroupsPerUnit a owl:DatatypeProperty ; - rdfs:domain csvw-safe:GroupingKey ; +csvw-eo:bounds.maxGroupsPerUnit a owl:DatatypeProperty ; + rdfs:domain csvw-eo:GroupingKey ; rdfs:range xsd:nonNegativeInteger ; rdfs:comment "l_0 bound: max partitions affected per privacy unit." . @@ -128,60 +128,60 @@ csvw-safe:bounds.maxGroupsPerUnit a owl:DatatypeProperty ; # Preprocessing Recommendations ################################################################################ -csvw-safe:rec.maxContributions a owl:DatatypeProperty ; +csvw-eo:rec.maxContributions a owl:DatatypeProperty ; rdfs:domain [ a owl:Class ; - owl:unionOf (csvw:Table csvw-safe:Partition csvw-safe:Contribution) + owl:unionOf (csvw:Table csvw-eo:Partition csvw-eo:Contribution) ] ; rdfs:range xsd:nonNegativeInteger . -csvw-safe:rec.maxGroupsPerUnit a owl:DatatypeProperty ; - rdfs:domain csvw-safe:GroupingKey ; +csvw-eo:rec.maxGroupsPerUnit a owl:DatatypeProperty ; + rdfs:domain csvw-eo:GroupingKey ; rdfs:range xsd:nonNegativeInteger . ################################################################################ # Contribution Wrapper ################################################################################ -csvw-safe:contributions a owl:ObjectProperty ; +csvw-eo:contributions a owl:ObjectProperty ; rdfs:domain [ a owl:Class ; - owl:unionOf (csvw:Table csvw-safe:Partition csvw-safe:GroupingKey) + owl:unionOf (csvw:Table csvw-eo:Partition csvw-eo:GroupingKey) ] ; - rdfs:range csvw-safe:Contribution . + rdfs:range csvw-eo:Contribution . ################################################################################ # Partition Predicate Model ################################################################################ -csvw-safe:predicate a owl:ObjectProperty ; - rdfs:domain csvw-safe:Partition ; - rdfs:range csvw-safe:Predicate . +csvw-eo:predicate a owl:ObjectProperty ; + rdfs:domain csvw-eo:Partition ; + rdfs:range csvw-eo:Predicate . -csvw-safe:Predicate a owl:Class . +csvw-eo:Predicate a owl:Class . -csvw-safe:partitionValue a owl:DatatypeProperty ; - rdfs:domain csvw-safe:Predicate ; +csvw-eo:partitionValue a owl:DatatypeProperty ; + rdfs:domain csvw-eo:Predicate ; rdfs:range xsd:string . -csvw-safe:lowerBound a owl:DatatypeProperty ; - rdfs:domain csvw-safe:Predicate ; +csvw-eo:lowerBound a owl:DatatypeProperty ; + rdfs:domain csvw-eo:Predicate ; rdfs:range xsd:decimal . -csvw-safe:upperBound a owl:DatatypeProperty ; - rdfs:domain csvw-safe:Predicate ; +csvw-eo:upperBound a owl:DatatypeProperty ; + rdfs:domain csvw-eo:Predicate ; rdfs:range xsd:decimal . -csvw-safe:lowerInclusive a owl:DatatypeProperty ; - rdfs:domain csvw-safe:Predicate ; +csvw-eo:lowerInclusive a owl:DatatypeProperty ; + rdfs:domain csvw-eo:Predicate ; rdfs:range xsd:boolean . -csvw-safe:upperInclusive a owl:DatatypeProperty ; - rdfs:domain csvw-safe:Predicate ; +csvw-eo:upperInclusive a owl:DatatypeProperty ; + rdfs:domain csvw-eo:Predicate ; rdfs:range xsd:boolean . -csvw-safe:components a owl:ObjectProperty ; - rdfs:domain csvw-safe:Predicate ; +csvw-eo:components a owl:ObjectProperty ; + rdfs:domain csvw-eo:Predicate ; rdfs:range rdf:Property ; rdfs:comment "Map column name to component predicate (JSON-LD object form)." . @@ -189,17 +189,17 @@ csvw-safe:components a owl:ObjectProperty ; # Structural Modeling (Synthetic Hints) ################################################################################ -csvw-safe:synth.nullableProportion a owl:DatatypeProperty ; +csvw-eo:synth.nullableProportion a owl:DatatypeProperty ; rdfs:domain csvw:Column ; rdfs:range xsd:decimal . -csvw-safe:synth.dependsOn a owl:ObjectProperty ; +csvw-eo:synth.dependsOn a owl:ObjectProperty ; rdfs:domain csvw:Column ; rdfs:range csvw:Column . -csvw-safe:synth.how a owl:DatatypeProperty ; +csvw-eo:synth.how a owl:DatatypeProperty ; rdfs:domain csvw:Column ; rdfs:range xsd:string . -csvw-safe:synth.mapping a owl:ObjectProperty ; +csvw-eo:synth.mapping a owl:ObjectProperty ; rdfs:domain csvw:Column . diff --git a/csvw-safe-library/examples/automated_penguin_metadata.yaml b/csvw-safe-library/examples/automated_penguin_metadata.yaml deleted file mode 100644 index 9e30115..0000000 --- a/csvw-safe-library/examples/automated_penguin_metadata.yaml +++ /dev/null @@ -1,110 +0,0 @@ -'@context': -- http://www.w3.org/ns/csvw -- dp: http://example.org/ns/csvw-dp-ext# -url: penguins.csv -tableSchema: - dp:maxContributions: 3 - dp:maxTableLength: 344 - dp:tableLength: 344 - columns: - - name: species - datatype: string - dp:privacyId: false - required: true - dp:nullableProportion: 0.0 - dp:publicPartitions: - - Adelie - - Chinstrap - - Gentoo - dp:maxNumPartitions: 3 - dp:maxPartitionLength: 152 - dp:maxInfluencedPartitions: 1 - dp:maxPartitionContribution: 3 - - name: island - datatype: string - dp:privacyId: false - required: true - dp:nullableProportion: 0.0 - dp:publicPartitions: - - Biscoe - - Dream - - Torgersen - dp:maxNumPartitions: 3 - dp:maxPartitionLength: 168 - dp:maxInfluencedPartitions: 1 - dp:maxPartitionContribution: 3 - - name: bill_length_mm - datatype: double - dp:privacyId: false - required: false - dp:nullableProportion: 0.01 - minimum: 32.0 - maximum: 60.0 - - name: bill_depth_mm - datatype: double - dp:privacyId: false - required: false - dp:nullableProportion: 0.01 - minimum: 13.0 - maximum: 22.0 - - name: flipper_length_mm - datatype: double - dp:privacyId: false - required: false - dp:nullableProportion: 0.01 - minimum: 172.0 - maximum: 231.0 - - name: body_mass_g - datatype: double - dp:privacyId: false - required: false - dp:nullableProportion: 0.01 - minimum: 2700.0 - maximum: 6300.0 - - name: sex - datatype: integer - dp:privacyId: false - required: true - dp:nullableProportion: 0.0 - dp:publicPartitions: - - 0 - - 1 - dp:maxNumPartitions: 2 - dp:maxPartitionLength: 179 - dp:maxInfluencedPartitions: 1 - dp:maxPartitionContribution: 3 - - name: penguin_id - datatype: double - dp:privacyId: true - required: true - dp:nullableProportion: 0.0 - minimum: 0.0 - maximum: 343.0 - - name: timestamp - datatype: dateTime - dp:privacyId: false - required: true - dp:nullableProportion: 0.0 - minimum: '2025-01-02 00:00:00' - maximum: '2025-12-30 00:00:00' - - name: favourite_number - datatype: integer - dp:privacyId: false - required: true - dp:nullableProportion: 0.0 - dp:publicPartitions: - - 0 - - 1 - - 2 - - 3 - - 4 - - 5 - - 6 - - 7 - - 8 - - 9 - - 10 - dp:maxNumPartitions: 11 - dp:maxPartitionLength: 35 - dp:maxInfluencedPartitions: 3 - dp:maxPartitionContribution: 2 diff --git a/csvw-safe-library/examples/metadata/penguin_metadata_column_level.json-ld b/csvw-safe-library/examples/metadata/penguin_metadata_column_level.json-ld deleted file mode 100644 index 705602c..0000000 --- a/csvw-safe-library/examples/metadata/penguin_metadata_column_level.json-ld +++ /dev/null @@ -1 +0,0 @@ -{"@context": ["http://www.w3.org/ns/csvw", "/opt/python/lib/python3.13/csvw-safe-context.jsonld"], "@type": "Table", "privacyUnit": "penguin_id", "maxContributions": 3, "maxLength": 344, "publicLength": 344, "tableSchema": {"columns": [{"@type": "Column", "name": "species", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "keyValues": ["Adelie", "Chinstrap", "Gentoo"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3, "maxLength": 152, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Column", "name": "island", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "keyValues": ["Biscoe", "Dream", "Torgersen"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3, "maxLength": 168, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Column", "name": "bill_length_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.294, "minimum": 32.1, "maximum": 59.6}, {"@type": "Column", "name": "bill_depth_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 13.1, "maximum": 21.5}, {"@type": "Column", "name": "flipper_length_mm", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.439, "minimum": 176.0, "maximum": 231.0}, {"@type": "Column", "name": "body_mass_g", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 2700.0, "maximum": 6300.0}, {"@type": "Column", "name": "sex", "datatype": "boolean", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": false, "maximum": true, "keyValues": [false, true], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 2, "maxLength": 179, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Column", "name": "penguin_id", "datatype": "positiveInteger", "required": true, "privacyId": true, "nullableProportion": 0.0, "minimum": 1, "maximum": 341}, {"@type": "Column", "name": "timestamp", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T00:00:00", "maximum": "2025-12-30T00:00:00"}, {"@type": "Column", "name": "timestamp_with_time", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T06:47:46", "maximum": "2025-12-30T19:27:11"}, {"@type": "Column", "name": "favourite_number", "datatype": "integer", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": 0, "maximum": 5, "keyValues": [0, 1, 2, 3, 4, 5], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 6, "maxLength": 66, "maxGroupsPerUnit": 3, "maxContributions": 3}]}} \ No newline at end of file diff --git a/csvw-safe-library/examples/metadata/penguin_metadata_column_level_column_group.json-ld b/csvw-safe-library/examples/metadata/penguin_metadata_column_level_column_group.json-ld deleted file mode 100644 index 808f26c..0000000 --- a/csvw-safe-library/examples/metadata/penguin_metadata_column_level_column_group.json-ld +++ /dev/null @@ -1 +0,0 @@ -{"@context": ["http://www.w3.org/ns/csvw", "/opt/python/lib/python3.13/csvw-safe-context.jsonld"], "@type": "Table", "privacyUnit": "penguin_id", "maxContributions": 3, "maxLength": 344, "publicLength": 344, "tableSchema": {"columns": [{"@type": "Column", "name": "species", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "keyValues": ["Adelie", "Chinstrap", "Gentoo"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3, "maxLength": 152, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Column", "name": "island", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "keyValues": ["Biscoe", "Dream", "Torgersen"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3, "maxLength": 168, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Column", "name": "bill_length_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.294, "minimum": 32.1, "maximum": 59.6}, {"@type": "Column", "name": "bill_depth_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 13.1, "maximum": 21.5}, {"@type": "Column", "name": "flipper_length_mm", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.439, "minimum": 176.0, "maximum": 231.0}, {"@type": "Column", "name": "body_mass_g", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 2700.0, "maximum": 6300.0}, {"@type": "Column", "name": "sex", "datatype": "boolean", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": false, "maximum": true, "keyValues": [false, true], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 2, "maxLength": 179, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Column", "name": "penguin_id", "datatype": "positiveInteger", "required": true, "privacyId": true, "nullableProportion": 0.0, "minimum": 1, "maximum": 341}, {"@type": "Column", "name": "timestamp", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T00:00:00", "maximum": "2025-12-30T00:00:00"}, {"@type": "Column", "name": "timestamp_with_time", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T06:47:46", "maximum": "2025-12-30T19:27:11"}, {"@type": "Column", "name": "favourite_number", "datatype": "integer", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": 0, "maximum": 5, "keyValues": [0, 1, 2, 3, 4, 5], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 6, "maxLength": 66, "maxGroupsPerUnit": 3, "maxContributions": 3}]}, "additionalInformation": [{"@type": "ColumnGroup", "columnsInGroup": ["species", "island"], "keyValues": [{"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Biscoe"}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Dream"}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Torgersen"}}, {"species": {"partitionValue": "Chinstrap"}, "island": {"partitionValue": "Dream"}}, {"species": {"partitionValue": "Gentoo"}, "island": {"partitionValue": "Biscoe"}}], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 5, "maxLength": 124, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "ColumnGroup", "columnsInGroup": ["species", "island", "favourite_number"], "keyValues": [{"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 0}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 1}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 2}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 3}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 4}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 5}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 0}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 1}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 2}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 3}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 4}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 5}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Torgersen"}, "favourite_number": {"partitionValue": 0}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Torgersen"}, "favourite_number": {"partitionValue": 1}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Torgersen"}, "favourite_number": {"partitionValue": 2}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Torgersen"}, "favourite_number": {"partitionValue": 3}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Torgersen"}, "favourite_number": {"partitionValue": 4}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Torgersen"}, "favourite_number": {"partitionValue": 5}}, {"species": {"partitionValue": "Chinstrap"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 0}}, {"species": {"partitionValue": "Chinstrap"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 1}}, {"species": {"partitionValue": "Chinstrap"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 2}}, {"species": {"partitionValue": "Chinstrap"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 3}}, {"species": {"partitionValue": "Chinstrap"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 4}}, {"species": {"partitionValue": "Chinstrap"}, "island": {"partitionValue": "Dream"}, "favourite_number": {"partitionValue": 5}}, {"species": {"partitionValue": "Gentoo"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 0}}, {"species": {"partitionValue": "Gentoo"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 1}}, {"species": {"partitionValue": "Gentoo"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 2}}, {"species": {"partitionValue": "Gentoo"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 3}}, {"species": {"partitionValue": "Gentoo"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 4}}, {"species": {"partitionValue": "Gentoo"}, "island": {"partitionValue": "Biscoe"}, "favourite_number": {"partitionValue": 5}}], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 30, "maxLength": 30, "maxGroupsPerUnit": 3, "maxContributions": 3}]} \ No newline at end of file diff --git a/csvw-safe-library/examples/metadata/penguin_metadata_fine_contrib_levels.json-ld b/csvw-safe-library/examples/metadata/penguin_metadata_fine_contrib_levels.json-ld deleted file mode 100644 index 163074a..0000000 --- a/csvw-safe-library/examples/metadata/penguin_metadata_fine_contrib_levels.json-ld +++ /dev/null @@ -1 +0,0 @@ -{"@context": ["http://www.w3.org/ns/csvw", "/opt/python/lib/python3.13/csvw-safe-context.jsonld"], "@type": "Table", "privacyUnit": "penguin_id", "maxContributions": 3, "maxLength": 344, "publicLength": 344, "tableSchema": {"columns": [{"@type": "Column", "name": "species", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": "Adelie"}, "maxLength": 152, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Chinstrap"}, "maxLength": 68, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Gentoo"}, "maxLength": 124, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": ["Adelie", "Chinstrap", "Gentoo"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "island", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "keyValues": ["Biscoe", "Dream", "Torgersen"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3, "maxLength": 168, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Column", "name": "bill_length_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.294, "minimum": 32.1, "maximum": 59.6, "partitions": [{"@type": "Partition", "predicate": {"lowerBound": 30.0, "upperBound": 40.0}, "maxLength": 74, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"lowerBound": 40.0, "upperBound": 50.0}, "maxLength": 128, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"lowerBound": 50.0, "upperBound": 60.0}, "maxLength": 41, "maxGroupsPerUnit": 3, "maxContributions": 2}], "maxNumPartitions": 3}, {"@type": "Column", "name": "bill_depth_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 13.1, "maximum": 21.5}, {"@type": "Column", "name": "flipper_length_mm", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.439, "minimum": 176.0, "maximum": 231.0}, {"@type": "Column", "name": "body_mass_g", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 2700.0, "maximum": 6300.0}, {"@type": "Column", "name": "sex", "datatype": "boolean", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": false, "maximum": true, "keyValues": [false, true], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 2}, {"@type": "Column", "name": "penguin_id", "datatype": "positiveInteger", "required": true, "privacyId": true, "nullableProportion": 0.0, "minimum": 1, "maximum": 341}, {"@type": "Column", "name": "timestamp", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T00:00:00", "maximum": "2025-12-30T00:00:00"}, {"@type": "Column", "name": "timestamp_with_time", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T06:47:46", "maximum": "2025-12-30T19:27:11"}, {"@type": "Column", "name": "favourite_number", "datatype": "integer", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": 0, "maximum": 5, "keyValues": [0, 1, 2, 3, 4, 5], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 6}]}} \ No newline at end of file diff --git a/csvw-safe-library/examples/metadata/penguin_metadata_fine_levels_column_group_continuous.json-ld b/csvw-safe-library/examples/metadata/penguin_metadata_fine_levels_column_group_continuous.json-ld deleted file mode 100644 index af15498..0000000 --- a/csvw-safe-library/examples/metadata/penguin_metadata_fine_levels_column_group_continuous.json-ld +++ /dev/null @@ -1 +0,0 @@ -{"@context": ["http://www.w3.org/ns/csvw", "/home/onyxia/work/csvw-safe/csvw-safe-library/csvw-safe-context.jsonld"], "@type": "Table", "privacyUnit": "penguin_id", "maxContributions": 3, "maxLength": 344, "publicLength": 344, "tableSchema": {"columns": [{"@type": "Column", "name": "species", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "rowDependencies": [{"dependsOn": "island", "dependencyType": "mapping", "valueMap": {"Biscoe": ["Adelie", "Gentoo"], "Dream": ["Adelie", "Chinstrap"], "Torgersen": ["Adelie"]}}, {"dependsOn": "penguin_id", "dependencyType": "fixedPerEntity"}, {"dependsOn": "timestamp_with_time", "dependencyType": "fixedPerEntity"}], "partitions": [{"@type": "Partition", "predicate": {"partitionValue": "Adelie"}, "maxLength": 152, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Chinstrap"}, "maxLength": 68, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Gentoo"}, "maxLength": 124, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": ["Adelie", "Chinstrap", "Gentoo"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "island", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "rowDependencies": [{"dependsOn": "species", "dependencyType": "mapping", "valueMap": {"Adelie": ["Torgersen", "Biscoe", "Dream"], "Chinstrap": ["Dream"], "Gentoo": ["Biscoe"]}}, {"dependsOn": "penguin_id", "dependencyType": "fixedPerEntity"}, {"dependsOn": "timestamp_with_time", "dependencyType": "fixedPerEntity"}], "keyValues": ["Biscoe", "Dream", "Torgersen"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3, "maxLength": 168, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Column", "name": "bill_length_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.294, "minimum": 32.1, "maximum": 59.6, "partitions": [{"@type": "Partition", "predicate": {"lowerBound": 30.0, "upperBound": 40.0}, "maxLength": 74, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"lowerBound": 40.0, "upperBound": 50.0}, "maxLength": 128, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"lowerBound": 50.0, "upperBound": 60.0}, "maxLength": 41, "maxGroupsPerUnit": 3, "maxContributions": 2}], "maxNumPartitions": 3}, {"@type": "Column", "name": "bill_depth_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 13.1, "maximum": 21.5}, {"@type": "Column", "name": "flipper_length_mm", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.439, "minimum": 176.0, "maximum": 231.0}, {"@type": "Column", "name": "body_mass_g", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 2700.0, "maximum": 6300.0}, {"@type": "Column", "name": "sex", "datatype": "boolean", "required": true, "privacyId": false, "nullableProportion": 0.0, "rowDependencies": [{"dependsOn": "penguin_id", "dependencyType": "fixedPerEntity"}, {"dependsOn": "timestamp_with_time", "dependencyType": "fixedPerEntity"}], "minimum": false, "maximum": true, "keyValues": [false, true], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 2}, {"@type": "Column", "name": "penguin_id", "datatype": "positiveInteger", "required": true, "privacyId": true, "nullableProportion": 0.0, "minimum": 1, "maximum": 343}, {"@type": "Column", "name": "timestamp", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T00:00:00", "maximum": "2025-12-30T00:00:00", "partitions": [{"@type": "Partition", "predicate": {"lowerBound": "2025-01-02T00:00:00", "upperBound": "2025-06-02T00:00:00"}, "maxLength": 139, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"lowerBound": "2025-06-02T00:00:00", "upperBound": "2025-12-30T00:00:00"}, "maxLength": 204, "maxGroupsPerUnit": 3, "maxContributions": 2}], "maxNumPartitions": 2}, {"@type": "Column", "name": "timestamp_with_time", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "rowDependencies": [{"dependsOn": "timestamp", "dependencyType": "bigger"}], "minimum": "2025-01-02T06:47:46", "maximum": "2025-12-30T19:27:11"}, {"@type": "Column", "name": "favourite_number", "datatype": "integer", "required": true, "privacyId": false, "nullableProportion": 0.0, "rowDependencies": [{"dependsOn": "timestamp_with_time", "dependencyType": "fixedPerEntity"}], "minimum": 0, "maximum": 5, "keyValues": [0, 1, 2, 3, 4, 5], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 6}]}, "additionalInformation": [{"@type": "ColumnGroup", "columnsInGroup": ["species", "bill_length_mm"], "partitions": [{"@type": "Partition", "predicate": {"species": {"partitionValue": "Adelie"}, "bill_length_mm": {"lowerBound": 30.0, "upperBound": 40.0}}, "maxLength": 74, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"species": {"partitionValue": "Adelie"}, "bill_length_mm": {"lowerBound": 40.0, "upperBound": 50.0}}, "maxLength": 30, "maxGroupsPerUnit": 2, "maxContributions": 2}, {"@type": "Partition", "predicate": {"species": {"partitionValue": "Chinstrap"}, "bill_length_mm": {"lowerBound": 40.0, "upperBound": 50.0}}, "maxLength": 25, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"species": {"partitionValue": "Chinstrap"}, "bill_length_mm": {"lowerBound": 50.0, "upperBound": 60.0}}, "maxLength": 21, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"species": {"partitionValue": "Gentoo"}, "bill_length_mm": {"lowerBound": 40.0, "upperBound": 50.0}}, "maxLength": 73, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"species": {"partitionValue": "Gentoo"}, "bill_length_mm": {"lowerBound": 50.0, "upperBound": 60.0}}, "maxLength": 20, "maxGroupsPerUnit": 2, "maxContributions": 2}], "keyValues": [{"species": {"partitionValue": "Adelie"}, "bill_length_mm": {"lowerBound": 30.0, "upperBound": 40.0}}, {"species": {"partitionValue": "Adelie"}, "bill_length_mm": {"lowerBound": 40.0, "upperBound": 50.0}}, {"species": {"partitionValue": "Chinstrap"}, "bill_length_mm": {"lowerBound": 40.0, "upperBound": 50.0}}, {"species": {"partitionValue": "Chinstrap"}, "bill_length_mm": {"lowerBound": 50.0, "upperBound": 60.0}}, {"species": {"partitionValue": "Gentoo"}, "bill_length_mm": {"lowerBound": 40.0, "upperBound": 50.0}}, {"species": {"partitionValue": "Gentoo"}, "bill_length_mm": {"lowerBound": 50.0, "upperBound": 60.0}}], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 6}]} \ No newline at end of file diff --git a/csvw-safe-library/examples/metadata/penguin_metadata_partition_level.json-ld b/csvw-safe-library/examples/metadata/penguin_metadata_partition_level.json-ld deleted file mode 100644 index 3610a51..0000000 --- a/csvw-safe-library/examples/metadata/penguin_metadata_partition_level.json-ld +++ /dev/null @@ -1 +0,0 @@ -{"@context": ["http://www.w3.org/ns/csvw", "/opt/python/lib/python3.13/csvw-safe-context.jsonld"], "@type": "Table", "privacyUnit": "penguin_id", "maxContributions": 3, "maxLength": 344, "publicLength": 344, "tableSchema": {"columns": [{"@type": "Column", "name": "species", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": "Adelie"}, "maxLength": 152, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Chinstrap"}, "maxLength": 68, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Gentoo"}, "maxLength": 124, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": ["Adelie", "Chinstrap", "Gentoo"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "island", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": "Biscoe"}, "maxLength": 168, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Dream"}, "maxLength": 124, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Torgersen"}, "maxLength": 52, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": ["Biscoe", "Dream", "Torgersen"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "bill_length_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.294, "minimum": 32.1, "maximum": 59.6}, {"@type": "Column", "name": "bill_depth_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 13.1, "maximum": 21.5}, {"@type": "Column", "name": "flipper_length_mm", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.439, "minimum": 176.0, "maximum": 231.0}, {"@type": "Column", "name": "body_mass_g", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 2700.0, "maximum": 6300.0}, {"@type": "Column", "name": "sex", "datatype": "boolean", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": false, "maximum": true, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": false}, "maxLength": 165, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": true}, "maxLength": 179, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": [false, true], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 2}, {"@type": "Column", "name": "penguin_id", "datatype": "positiveInteger", "required": true, "privacyId": true, "nullableProportion": 0.0, "minimum": 1, "maximum": 341}, {"@type": "Column", "name": "timestamp", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T00:00:00", "maximum": "2025-12-30T00:00:00"}, {"@type": "Column", "name": "timestamp_with_time", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T06:47:46", "maximum": "2025-12-30T19:27:11"}, {"@type": "Column", "name": "favourite_number", "datatype": "integer", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": 0, "maximum": 5, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": 0}, "maxLength": 60, "maxGroupsPerUnit": 3, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 1}, "maxLength": 57, "maxGroupsPerUnit": 2, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 2}, "maxLength": 59, "maxGroupsPerUnit": 3, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 3}, "maxLength": 45, "maxGroupsPerUnit": 3, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 4}, "maxLength": 57, "maxGroupsPerUnit": 2, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 5}, "maxLength": 66, "maxGroupsPerUnit": 3, "maxContributions": 3}], "keyValues": [0, 1, 2, 3, 4, 5], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 6}]}} \ No newline at end of file diff --git a/csvw-safe-library/examples/metadata/penguin_metadata_partition_level_column_group.json-ld b/csvw-safe-library/examples/metadata/penguin_metadata_partition_level_column_group.json-ld deleted file mode 100644 index 2e6deae..0000000 --- a/csvw-safe-library/examples/metadata/penguin_metadata_partition_level_column_group.json-ld +++ /dev/null @@ -1 +0,0 @@ -{"@context": ["http://www.w3.org/ns/csvw", "/opt/python/lib/python3.13/csvw-safe-context.jsonld"], "@type": "Table", "privacyUnit": "penguin_id", "maxContributions": 3, "maxLength": 344, "publicLength": 344, "tableSchema": {"columns": [{"@type": "Column", "name": "species", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": "Adelie"}, "maxLength": 152, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Chinstrap"}, "maxLength": 68, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Gentoo"}, "maxLength": 124, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": ["Adelie", "Chinstrap", "Gentoo"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "island", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": "Biscoe"}, "maxLength": 168, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Dream"}, "maxLength": 124, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Torgersen"}, "maxLength": 52, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": ["Biscoe", "Dream", "Torgersen"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "bill_length_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.294, "minimum": 32.1, "maximum": 59.6}, {"@type": "Column", "name": "bill_depth_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 13.1, "maximum": 21.5}, {"@type": "Column", "name": "flipper_length_mm", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.439, "minimum": 176.0, "maximum": 231.0}, {"@type": "Column", "name": "body_mass_g", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 2700.0, "maximum": 6300.0}, {"@type": "Column", "name": "sex", "datatype": "boolean", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": false, "maximum": true, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": false}, "maxLength": 165, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": true}, "maxLength": 179, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": [false, true], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 2}, {"@type": "Column", "name": "penguin_id", "datatype": "positiveInteger", "required": true, "privacyId": true, "nullableProportion": 0.0, "minimum": 1, "maximum": 341}, {"@type": "Column", "name": "timestamp", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T00:00:00", "maximum": "2025-12-30T00:00:00"}, {"@type": "Column", "name": "timestamp_with_time", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T06:47:46", "maximum": "2025-12-30T19:27:11"}, {"@type": "Column", "name": "favourite_number", "datatype": "integer", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": 0, "maximum": 5, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": 0}, "maxLength": 60, "maxGroupsPerUnit": 3, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 1}, "maxLength": 57, "maxGroupsPerUnit": 2, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 2}, "maxLength": 59, "maxGroupsPerUnit": 3, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 3}, "maxLength": 45, "maxGroupsPerUnit": 3, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 4}, "maxLength": 57, "maxGroupsPerUnit": 2, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 5}, "maxLength": 66, "maxGroupsPerUnit": 3, "maxContributions": 3}], "keyValues": [0, 1, 2, 3, 4, 5], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 6}]}, "additionalInformation": [{"@type": "ColumnGroup", "columnsInGroup": ["species", "island"], "partitions": [{"@type": "Partition", "predicate": {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Biscoe"}}, "maxLength": 44, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Dream"}}, "maxLength": 56, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Torgersen"}}, "maxLength": 52, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"species": {"partitionValue": "Chinstrap"}, "island": {"partitionValue": "Dream"}}, "maxLength": 68, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"species": {"partitionValue": "Gentoo"}, "island": {"partitionValue": "Biscoe"}}, "maxLength": 124, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": [{"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Biscoe"}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Dream"}}, {"species": {"partitionValue": "Adelie"}, "island": {"partitionValue": "Torgersen"}}, {"species": {"partitionValue": "Chinstrap"}, "island": {"partitionValue": "Dream"}}, {"species": {"partitionValue": "Gentoo"}, "island": {"partitionValue": "Biscoe"}}], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 5}]} \ No newline at end of file diff --git a/csvw-safe-library/examples/metadata/penguin_metadata_partition_level_with_continuous.json-ld b/csvw-safe-library/examples/metadata/penguin_metadata_partition_level_with_continuous.json-ld deleted file mode 100644 index a2fdf2c..0000000 --- a/csvw-safe-library/examples/metadata/penguin_metadata_partition_level_with_continuous.json-ld +++ /dev/null @@ -1 +0,0 @@ -{"@context": ["http://www.w3.org/ns/csvw", "/opt/python/lib/python3.13/csvw-safe-context.jsonld"], "@type": "Table", "privacyUnit": "penguin_id", "maxContributions": 3, "maxLength": 344, "publicLength": 344, "tableSchema": {"columns": [{"@type": "Column", "name": "species", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": "Adelie"}, "maxLength": 152, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Chinstrap"}, "maxLength": 68, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Gentoo"}, "maxLength": 124, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": ["Adelie", "Chinstrap", "Gentoo"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "island", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": "Biscoe"}, "maxLength": 168, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Dream"}, "maxLength": 124, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": "Torgersen"}, "maxLength": 52, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": ["Biscoe", "Dream", "Torgersen"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "bill_length_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.294, "minimum": 32.1, "maximum": 59.6, "partitions": [{"@type": "Partition", "predicate": {"lowerBound": 30.0, "upperBound": 40.0}, "maxLength": 74, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"lowerBound": 40.0, "upperBound": 50.0}, "maxLength": 128, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"lowerBound": 50.0, "upperBound": 60.0}, "maxLength": 41, "maxGroupsPerUnit": 3, "maxContributions": 2}], "maxNumPartitions": 3}, {"@type": "Column", "name": "bill_depth_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 13.1, "maximum": 21.5}, {"@type": "Column", "name": "flipper_length_mm", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.439, "minimum": 176.0, "maximum": 231.0}, {"@type": "Column", "name": "body_mass_g", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 2700.0, "maximum": 6300.0}, {"@type": "Column", "name": "sex", "datatype": "boolean", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": false, "maximum": true, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": false}, "maxLength": 165, "maxGroupsPerUnit": 3, "maxContributions": 1}, {"@type": "Partition", "predicate": {"partitionValue": true}, "maxLength": 179, "maxGroupsPerUnit": 3, "maxContributions": 1}], "keyValues": [false, true], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 2}, {"@type": "Column", "name": "penguin_id", "datatype": "positiveInteger", "required": true, "privacyId": true, "nullableProportion": 0.0, "minimum": 1, "maximum": 341}, {"@type": "Column", "name": "timestamp", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T00:00:00", "maximum": "2025-12-30T00:00:00", "partitions": [{"@type": "Partition", "predicate": {"lowerBound": "2025-01-02T00:00:00", "upperBound": "2025-06-02T00:00:00"}, "maxLength": 139, "maxGroupsPerUnit": 3, "maxContributions": 2}, {"@type": "Partition", "predicate": {"lowerBound": "2025-06-02T00:00:00", "upperBound": "2025-12-30T00:00:00"}, "maxLength": 204, "maxGroupsPerUnit": 3, "maxContributions": 2}], "maxNumPartitions": 2}, {"@type": "Column", "name": "timestamp_with_time", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T06:47:46", "maximum": "2025-12-30T19:27:11"}, {"@type": "Column", "name": "favourite_number", "datatype": "integer", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": 0, "maximum": 5, "partitions": [{"@type": "Partition", "predicate": {"partitionValue": 0}, "maxLength": 60, "maxGroupsPerUnit": 3, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 1}, "maxLength": 57, "maxGroupsPerUnit": 2, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 2}, "maxLength": 59, "maxGroupsPerUnit": 3, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 3}, "maxLength": 45, "maxGroupsPerUnit": 3, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 4}, "maxLength": 57, "maxGroupsPerUnit": 2, "maxContributions": 3}, {"@type": "Partition", "predicate": {"partitionValue": 5}, "maxLength": 66, "maxGroupsPerUnit": 3, "maxContributions": 3}], "keyValues": [0, 1, 2, 3, 4, 5], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 6}]}} \ No newline at end of file diff --git a/csvw-safe-library/examples/metadata/penguin_metadata_table_level.json-ld b/csvw-safe-library/examples/metadata/penguin_metadata_table_level.json-ld deleted file mode 100644 index 9ca8e38..0000000 --- a/csvw-safe-library/examples/metadata/penguin_metadata_table_level.json-ld +++ /dev/null @@ -1 +0,0 @@ -{"@context": ["http://www.w3.org/ns/csvw", "/opt/python/lib/python3.13/csvw-safe-context.jsonld"], "@type": "Table", "privacyUnit": "penguin_id", "maxContributions": 3, "maxLength": 344, "publicLength": 344, "tableSchema": {"columns": [{"@type": "Column", "name": "species", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0}, {"@type": "Column", "name": "island", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0}, {"@type": "Column", "name": "bill_length_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.294, "minimum": 32.1, "maximum": 59.6}, {"@type": "Column", "name": "bill_depth_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 13.1, "maximum": 21.5}, {"@type": "Column", "name": "flipper_length_mm", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.439, "minimum": 176.0, "maximum": 231.0}, {"@type": "Column", "name": "body_mass_g", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 2700.0, "maximum": 6300.0}, {"@type": "Column", "name": "sex", "datatype": "boolean", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": false, "maximum": true}, {"@type": "Column", "name": "penguin_id", "datatype": "positiveInteger", "required": true, "privacyId": true, "nullableProportion": 0.0, "minimum": 1, "maximum": 341}, {"@type": "Column", "name": "timestamp", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T00:00:00", "maximum": "2025-12-30T00:00:00"}, {"@type": "Column", "name": "timestamp_with_time", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T06:47:46", "maximum": "2025-12-30T19:27:11"}, {"@type": "Column", "name": "favourite_number", "datatype": "integer", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": 0, "maximum": 5}]}} \ No newline at end of file diff --git a/csvw-safe-library/examples/metadata/penguin_metadata_table_with_keys_level.json-ld b/csvw-safe-library/examples/metadata/penguin_metadata_table_with_keys_level.json-ld deleted file mode 100644 index 9cad2cb..0000000 --- a/csvw-safe-library/examples/metadata/penguin_metadata_table_with_keys_level.json-ld +++ /dev/null @@ -1 +0,0 @@ -{"@context": ["http://www.w3.org/ns/csvw", "/opt/python/lib/python3.13/csvw-safe-context.jsonld"], "@type": "Table", "privacyUnit": "penguin_id", "maxContributions": 3, "maxLength": 344, "publicLength": 344, "tableSchema": {"columns": [{"@type": "Column", "name": "species", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "keyValues": ["Adelie", "Chinstrap", "Gentoo"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "island", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "keyValues": ["Biscoe", "Dream", "Torgersen"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "bill_length_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.294, "minimum": 32.1, "maximum": 59.6}, {"@type": "Column", "name": "bill_depth_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 13.1, "maximum": 21.5}, {"@type": "Column", "name": "flipper_length_mm", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.439, "minimum": 176.0, "maximum": 231.0}, {"@type": "Column", "name": "body_mass_g", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 2700.0, "maximum": 6300.0}, {"@type": "Column", "name": "sex", "datatype": "boolean", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": false, "maximum": true, "keyValues": [false, true], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 2}, {"@type": "Column", "name": "penguin_id", "datatype": "positiveInteger", "required": true, "privacyId": true, "nullableProportion": 0.0, "minimum": 1, "maximum": 341}, {"@type": "Column", "name": "timestamp", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T00:00:00", "maximum": "2025-12-30T00:00:00"}, {"@type": "Column", "name": "timestamp_with_time", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T06:47:46", "maximum": "2025-12-30T19:27:11"}, {"@type": "Column", "name": "favourite_number", "datatype": "integer", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": 0, "maximum": 5, "keyValues": [0, 1, 2, 3, 4, 5], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 6}]}} \ No newline at end of file diff --git a/csvw-safe-library/examples/metadata/penguin_metadata_table_with_keys_with_dependencies.json-ld b/csvw-safe-library/examples/metadata/penguin_metadata_table_with_keys_with_dependencies.json-ld deleted file mode 100644 index 65f7f05..0000000 --- a/csvw-safe-library/examples/metadata/penguin_metadata_table_with_keys_with_dependencies.json-ld +++ /dev/null @@ -1 +0,0 @@ -{"@context": ["http://www.w3.org/ns/csvw", "/opt/python/lib/python3.13/csvw-safe-context.jsonld"], "@type": "Table", "privacyUnit": "penguin_id", "maxContributions": 3, "maxLength": 344, "publicLength": 344, "tableSchema": {"columns": [{"@type": "Column", "name": "species", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "rowDependencies": [{"dependsOn": "island", "dependencyType": "mapping", "valueMap": {"Biscoe": ["Adelie", "Gentoo"], "Dream": ["Adelie", "Chinstrap"], "Torgersen": ["Adelie"]}}, {"dependsOn": "penguin_id", "dependencyType": "fixedPerEntity"}, {"dependsOn": "timestamp_with_time", "dependencyType": "fixedPerEntity"}], "keyValues": ["Adelie", "Chinstrap", "Gentoo"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "island", "datatype": "string", "required": true, "privacyId": false, "nullableProportion": 0.0, "rowDependencies": [{"dependsOn": "species", "dependencyType": "mapping", "valueMap": {"Adelie": ["Torgersen", "Biscoe", "Dream"], "Chinstrap": ["Dream"], "Gentoo": ["Biscoe"]}}, {"dependsOn": "penguin_id", "dependencyType": "fixedPerEntity"}, {"dependsOn": "timestamp_with_time", "dependencyType": "fixedPerEntity"}], "keyValues": ["Biscoe", "Dream", "Torgersen"], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 3}, {"@type": "Column", "name": "bill_length_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.294, "minimum": 32.1, "maximum": 59.6}, {"@type": "Column", "name": "bill_depth_mm", "datatype": "double", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 13.1, "maximum": 21.5}, {"@type": "Column", "name": "flipper_length_mm", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.439, "minimum": 176.0, "maximum": 231.0}, {"@type": "Column", "name": "body_mass_g", "datatype": "positiveInteger", "required": false, "privacyId": false, "nullableProportion": 0.006, "minimum": 2700.0, "maximum": 6300.0}, {"@type": "Column", "name": "sex", "datatype": "boolean", "required": true, "privacyId": false, "nullableProportion": 0.0, "rowDependencies": [{"dependsOn": "penguin_id", "dependencyType": "fixedPerEntity"}, {"dependsOn": "timestamp_with_time", "dependencyType": "fixedPerEntity"}], "minimum": false, "maximum": true, "keyValues": [false, true], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 2}, {"@type": "Column", "name": "penguin_id", "datatype": "positiveInteger", "required": true, "privacyId": true, "nullableProportion": 0.0, "minimum": 1, "maximum": 341}, {"@type": "Column", "name": "timestamp", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "minimum": "2025-01-02T00:00:00", "maximum": "2025-12-30T00:00:00"}, {"@type": "Column", "name": "timestamp_with_time", "datatype": "dateTime", "required": true, "privacyId": false, "nullableProportion": 0.0, "rowDependencies": [{"dependsOn": "timestamp", "dependencyType": "bigger"}], "minimum": "2025-01-02T06:47:46", "maximum": "2025-12-30T19:27:11"}, {"@type": "Column", "name": "favourite_number", "datatype": "integer", "required": true, "privacyId": false, "nullableProportion": 0.0, "rowDependencies": [{"dependsOn": "timestamp_with_time", "dependencyType": "fixedPerEntity"}], "minimum": 0, "maximum": 5, "keyValues": [0, 1, 2, 3, 4, 5], "invariantPublicKeys": true, "exhaustiveKeys": true, "maxNumPartitions": 6}]}} \ No newline at end of file diff --git a/docs/api/dummy_generation.md b/docs/api/dummy_generation.md index 5b2725f..a10570a 100644 --- a/docs/api/dummy_generation.md +++ b/docs/api/dummy_generation.md @@ -6,10 +6,10 @@ Synthetic dataset generation utilities. ## Main API -::: csvw_safe.make_dummy_from_metadata +::: csvw_eo.make_dummy_from_metadata --- ## Series Generation Utilities -::: csvw_safe.generate_series \ No newline at end of file +::: csvw_eo.generate_series \ No newline at end of file diff --git a/docs/api/index.md b/docs/api/index.md index 01ecf74..ade4bc2 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -1,6 +1,6 @@ # API Reference -The CSVW-SAFE API is organized into several functional groups: +The CSVW-EO API is organized into several functional groups: - Metadata generation - Dummy data generation diff --git a/docs/api/metadata_generation.md b/docs/api/metadata_generation.md index 6271952..c4ef3f8 100644 --- a/docs/api/metadata_generation.md +++ b/docs/api/metadata_generation.md @@ -1,15 +1,15 @@ # Metadata Generation -Tools for generating CSVW-SAFE metadata from datasets. +Tools for generating CSVW-EO metadata from datasets. --- ## Main API -::: csvw_safe.make_metadata_from_data +::: csvw_eo.make_metadata_from_data --- ## Supporting Utilities -::: csvw_safe.datatypes \ No newline at end of file +::: csvw_eo.datatypes \ No newline at end of file diff --git a/docs/api/models.md b/docs/api/models.md index 747b220..7bc25dc 100644 --- a/docs/api/models.md +++ b/docs/api/models.md @@ -6,10 +6,10 @@ Core metadata models and schema definitions. ## Metadata Structure -::: csvw_safe.metadata_structure +::: csvw_eo.metadata_structure --- ## Constants -::: csvw_safe.constants \ No newline at end of file +::: csvw_eo.constants \ No newline at end of file diff --git a/docs/api/opendp.md b/docs/api/opendp.md index 2aaa14f..289e5aa 100644 --- a/docs/api/opendp.md +++ b/docs/api/opendp.md @@ -1,15 +1,15 @@ # OpenDP Integration -Utilities for integrating CSVW-SAFE metadata with OpenDP. +Utilities for integrating CSVW-EO metadata with OpenDP. --- ## OpenDP Context -::: csvw_safe.csvw_to_opendp_context +::: csvw_eo.csvw_to_opendp_context --- ## OpenDP Margins -::: csvw_safe.csvw_to_opendp_margins \ No newline at end of file +::: csvw_eo.csvw_to_opendp_margins \ No newline at end of file diff --git a/docs/api/smartnoise_sql.md b/docs/api/smartnoise_sql.md index 8282864..34fc9e1 100644 --- a/docs/api/smartnoise_sql.md +++ b/docs/api/smartnoise_sql.md @@ -1,7 +1,7 @@ # SmartNoise SQL Integration -Convert CSVW-SAFE metadata into SmartNoise SQL configuration. +Convert CSVW-EO metadata into SmartNoise SQL configuration. --- -::: csvw_safe.csvw_to_smartnoise_sql \ No newline at end of file +::: csvw_eo.csvw_to_smartnoise_sql \ No newline at end of file diff --git a/docs/api/utilities.md b/docs/api/utilities.md index 3d90483..8e9560e 100644 --- a/docs/api/utilities.md +++ b/docs/api/utilities.md @@ -4,4 +4,4 @@ General helper functions and shared utilities. --- -::: csvw_safe.utils \ No newline at end of file +::: csvw_eo.utils \ No newline at end of file diff --git a/docs/api/validation.md b/docs/api/validation.md index 4f0e841..854eff0 100644 --- a/docs/api/validation.md +++ b/docs/api/validation.md @@ -1,21 +1,21 @@ # Validation -Validation utilities for CSVW-SAFE metadata and generated datasets. +Validation utilities for CSVW-EO metadata and generated datasets. --- ## Metadata Validation -::: csvw_safe.validate_metadata +::: csvw_eo.validate_metadata --- ## SHACL Validation -::: csvw_safe.validate_metadata_shacl +::: csvw_eo.validate_metadata_shacl --- ## Structural Validation -::: csvw_safe.assert_same_structure \ No newline at end of file +::: csvw_eo.assert_same_structure \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 0fae803..2cba2d4 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,18 +1,26 @@ -# CSVW-SAFE +# CSVW-EO -CSVW-SAFE extends the W3C -[CSV on the Web (CSVW)](https://www.w3.org/TR/tabular-data-model/) with privacy-safe metadata for differential privacy workflows and dummy dataset generation. +CSVW-EO extends the W3C [CSV on the Web (CSVW)](https://www.w3.org/TR/tabular-data-model/) with metadata for differential privacy workflows and dummy dataset generation. + +EO stands for "Eyes-Off", highlighting privacy-preserving workflows in which sensitive data remains unobserved by users while still enabling metadata generation, validation, and dummy dataset creation. ## Features - Metadata generation +- Metadata validation - Dummy data generation -- SHACL validation -- OpenDP integration -- SmartNoise SQL integration +- [SHACL validation](https://github.com/dscc-admin-ch/csvw-eo/blob/main/csvw-eo-constraints.ttl) +- [opendp](https://docs.opendp.org/en/stable/index.html) integration +- [smartnoise_sql](https://docs.smartnoise.org/sql/index.html#metadata) integration ## Documentation - Vocabulary - Python library - API reference + +## Work in Progress + +CSVW-EO is currently under active development. The project is evolving, and new features, improvements, and documentation updates are being added continuously. + +Contributions, feedback, and discussions are welcome. A roadmap of planned tasks and ongoing work can be found in the project board: [board](https://github.com/orgs/dscc-admin-ch/projects/10/views/1). \ No newline at end of file diff --git a/docs/library/dummy_generation.md b/docs/library/dummy_generation.md index a6520db..0d0f20d 100644 --- a/docs/library/dummy_generation.md +++ b/docs/library/dummy_generation.md @@ -1,6 +1,6 @@ # Dummy Dataset Generation -The `make_dummy_from_metadata.py` utility generates synthetic datasets from CSVW-SAFE metadata. +The `make_dummy_from_metadata.py` utility generates synthetic datasets from CSVW-EO metadata. --- diff --git a/docs/library/installation.md b/docs/library/installation.md index 32b61c5..1936f01 100644 --- a/docs/library/installation.md +++ b/docs/library/installation.md @@ -10,7 +10,7 @@ ## Install from PyPI ```bash -pip install csvw-safe +pip install csvw-eo ``` ## Development Installation @@ -18,9 +18,9 @@ pip install csvw-safe Clone the repository and install development dependencies: ```bash -git clone https://github.com/dscc-admin-ch/csvw-safe-library.git +git clone https://github.com/dscc-admin-ch/csvw-eo-library.git -cd csvw-safe-library +cd csvw-eo-library pip install -e .[dev] ``` @@ -28,7 +28,7 @@ pip install -e .[dev] ## Run Tests ```bash -pytest --cov=csvw_safe --cov-report=term-missing tests/ +pytest --cov=csvw_eo --cov-report=term-missing tests/ ``` ## Run linter diff --git a/docs/library/integration.md b/docs/library/integration.md index b906c4a..44266c6 100644 --- a/docs/library/integration.md +++ b/docs/library/integration.md @@ -1,6 +1,6 @@ # Integrations -CSVW-SAFE metadata can be integrated with Differential Privacy libraries and systems. +CSVW-EO metadata can be integrated with Differential Privacy libraries and systems. Currently supported integrations include: @@ -11,13 +11,13 @@ Currently supported integrations include: # SmartNoise SQL Integration -The `csvw_to_smartnoise_sql.py` utility converts CSVW-SAFE metadata into SmartNoise SQL YAML configuration. +The `csvw_to_smartnoise_sql.py` utility converts CSVW-EO metadata into SmartNoise SQL YAML configuration. --- ## Supported Mappings -| CSVW-SAFE | SmartNoise SQL | +| CSVW-EO | SmartNoise SQL | |---|---| | `maxContributions` | `max_ids` | | `minimum` | `lower` | @@ -54,7 +54,7 @@ The `csvw_to_opendp_context.py` utility creates OpenDP contexts from metadata an ```bash import polars as pl -from csvw_safe.csvw_to_opendp_context import ( +from csvw_eo.csvw_to_opendp_context import ( csvw_to_opendp_context, ) @@ -70,6 +70,6 @@ context = csvw_to_opendp_context( ## Design Goal -CSVW-SAFE aims to provide a portable metadata layer between Differential Privacy systems. +CSVW-EO aims to provide a portable metadata layer between Differential Privacy systems. The metadata should remain implementation-independent while still enabling automated DP workflows. \ No newline at end of file diff --git a/docs/library/metadata_generation.md b/docs/library/metadata_generation.md index 4fa9c4f..8cd6663 100644 --- a/docs/library/metadata_generation.md +++ b/docs/library/metadata_generation.md @@ -1,6 +1,6 @@ # Metadata Generation -The `make_metadata_from_data.py` utility generates baseline CSVW-SAFE metadata from an existing dataset. +The `make_metadata_from_data.py` utility generates baseline CSVW-EO metadata from an existing dataset. --- diff --git a/docs/library/overview.md b/docs/library/overview.md index 7d5964b..fa5fcf7 100644 --- a/docs/library/overview.md +++ b/docs/library/overview.md @@ -1,6 +1,6 @@ -# CSVW-SAFE Python Library +# CSVW-EO Python Library -The `csvw-safe` Python package provides utilities for generating, validating, and using CSVW-SAFE metadata for safe metadata sharing and Differential Privacy (DP) workflows. +The `csvw-eo` Python package provides utilities for generating, validating, and using CSVW-EO metadata for safe metadata sharing and Differential Privacy (DP) workflows. The library helps: @@ -26,7 +26,7 @@ The library includes the following tools: | Script | Purpose | |---|---| -| `make_metadata_from_data.py` | Generate CSVW-SAFE metadata from data | +| `make_metadata_from_data.py` | Generate CSVW-EO metadata from data | | `make_dummy_from_metadata.py` | Generate dummy datasets from metadata | | `validate_metadata.py` | Validate metadata structure | | `validate_metadata_shacl.py` | Validate metadata against SHACL constraints | diff --git a/csvw-safe-library/TableMetadata.md b/docs/library/table_metadata.md similarity index 91% rename from csvw-safe-library/TableMetadata.md rename to docs/library/table_metadata.md index 22b3f5c..687d981 100644 --- a/csvw-safe-library/TableMetadata.md +++ b/docs/library/table_metadata.md @@ -1,8 +1,8 @@ -# TableMetadata (CSVW-SAFE) +# TableMetadata (CSVW-EO) ## Overview -`TableMetadata` is the top-level container for describing a CSVW-SAFE table in the library. It aggregates: +`TableMetadata` is the top-level container for describing a CSVW-EO table in the library. It aggregates: - Global privacy constraints - Column-level metadata @@ -45,9 +45,9 @@ It supports: ## `to_dict()` and `from_dict()` Representation -The `to_dict()` method converts the `TableMetadata` instance into a CSVW-SAFE compliant JSON-LD dictionary. +The `to_dict()` method converts the `TableMetadata` instance into a CSVW-EO compliant JSON-LD dictionary. -The `from_dict()` method reconstructs a `TableMetadata` instance from a CSVW-SAFE compliant JSON-LD dictionary. +The `from_dict()` method reconstructs a `TableMetadata` instance from a CSVW-EO compliant JSON-LD dictionary. ### Field Mapping @@ -89,7 +89,7 @@ The `from_dict()` method reconstructs a `TableMetadata` instance from a CSVW-SAF - `tableSchema.columns` is **required** and always parsed - `additionalInformation` is **optional** - Missing optional fields do **not** raise errors (handled by Pydantic defaults) -- (For now): Input is assumed to already follow CSVW-SAFE structure (no deep validation layer beyond model constraints). TODO: be more strict here (like datatypes options). +- (For now): Input is assumed to already follow CSVW-EO structure (no deep validation layer beyond model constraints). TODO: be more strict here (like datatypes options). ## Example @@ -110,7 +110,7 @@ Serialized json-ld output after `json_repr = metadata.to_dict()`: json_repr = { "@context": [ "http://www.w3.org/ns/csvw", - "path/to/csvw-safe-context.jsonld" + "path/to/csvw-eo-context.jsonld" ], "@type": "Table", "privacyUnit": "user_id", @@ -141,7 +141,7 @@ metadata = TableMetadata.from_dict(json_repr) ## Summary -`TableMetadata` is the entry point for CSVW-SAFE metadata, providing: +`TableMetadata` is the entry point for CSVW-EO metadata, providing: - A structured way to define dataset privacy constraints - Full schema description (columns + groups) - Bidirectional conversion: diff --git a/docs/library/validation.md b/docs/library/validation.md index a52ce75..a6f2e64 100644 --- a/docs/library/validation.md +++ b/docs/library/validation.md @@ -1,6 +1,6 @@ # Metadata Validation -CSVW-SAFE provides two validation layers: +CSVW-EO provides two validation layers: 1. Internal schema validation 2. SHACL validation @@ -44,7 +44,7 @@ TODO: As the dataset is not published yet, it is not functional for now (or put ```bash python validate_metadata_shacl.py \ metadata.json \ - csvw-safe-constraints.ttl + csvw-eo-constraints.ttl ``` ## Validation Recommendations diff --git a/docs/library/workflows.md b/docs/library/workflows.md index e21bd04..bdd2762 100644 --- a/docs/library/workflows.md +++ b/docs/library/workflows.md @@ -1,6 +1,6 @@ # Typical Workflows -CSVW-SAFE workflows usually follow four main steps: +CSVW-EO workflows usually follow four main steps: 1. Generate metadata with the minimal details level 2. Review and validate metadata (remove non public information) @@ -9,6 +9,14 @@ CSVW-SAFE workflows usually follow four main steps: --- +# Jupyter notebook example + +The [CSVW-EO DEMO notebook](https://github.com/dscc-admin-ch/csvw-eo/blob/main/csvw-eo-library/examples/Use-Library.ipynb) provides a complete end-to-end demonstration of the workflow, including several practical usage examples. + +The repository also includes a set of example metadata files located in: [examples/metadata/](https://github.com/dscc-admin-ch/csvw-eo/tree/main/csvw-eo-library/examples/metadata). These examples illustrate how metadata can be defined at different levels of precision for use in CSVW-EO workflows. + +--- + # CLI Workflow ## 1. Generate Metadata @@ -41,7 +49,7 @@ python validate_metadata.py metadata.json ```bash python validate_metadata_shacl.py \ metadata.json \ - csvw-safe-constraints.ttl + csvw-eo-constraints.ttl ``` ## 4. Generate Dummy Dataset @@ -66,9 +74,9 @@ python assert_same_structure.py \ ```bash import pandas as pd -from csvw_safe.make_metadata_from_data import make_metadata_from_data -from csvw_safe.validate_metadata import validate_metadata -from csvw_safe.make_dummy_from_metadata import make_dummy_from_metadata +from csvw_eo.make_metadata_from_data import make_metadata_from_data +from csvw_eo.validate_metadata import validate_metadata +from csvw_eo.make_dummy_from_metadata import make_dummy_from_metadata df = pd.read_csv("data.csv") @@ -97,8 +105,14 @@ dummy_df = make_dummy_from_metadata( ## Important Warning -**Automatically generated metadata is not safe.** +!!! danger "Warning" + + **Automatically generated metadata is not safe.** + +!!! danger "Warning" + + **Human review is mandatory before publication or sharing.** -**Human review is mandatory before publication or sharing.** +!!! danger "Warning" -**When in doubt, remove information.** \ No newline at end of file + **When in doubt, remove information.** \ No newline at end of file diff --git a/docs/vocabulary/classes.md b/docs/vocabulary/classes.md index de8f563..f30f2a8 100644 --- a/docs/vocabulary/classes.md +++ b/docs/vocabulary/classes.md @@ -1,13 +1,13 @@ -# CSVW-SAFE Classes +# CSVW-EO Classes -CSVW-SAFE defines four main classes. +CSVW-EO defines four main classes. | Class | Purpose | |---|---| | `csvw:Table` | Dataset-level metadata | | `csvw:Column` | Single-column metadata | -| `csvw-safe:ColumnGroup` | Multi-column grouping metadata | -| `csvw-safe:Partition` | Public partition definitions | +| `csvw-eo:ColumnGroup` | Multi-column grouping metadata | +| `csvw-eo:Partition` | Public partition definitions | ## Table @@ -62,7 +62,7 @@ Example: ## ColumnGroup -A `csvw-safe:ColumnGroup` describes grouping assumptions on multiple columns simultaneously. +A `csvw-eo:ColumnGroup` describes grouping assumptions on multiple columns simultaneously. Typical use cases: @@ -107,7 +107,7 @@ It may contain: ## Partition -A `csvw-safe:Partition` defines a region of a value domain. +A `csvw-eo:Partition` defines a region of a value domain. Examples: @@ -120,15 +120,15 @@ Partitions are indentified by predicates and may contain: - contribution bounds - public lengths -A `csvw:Column` or a `csvw-safe:ColumnGroup` can have a list of partitions in the field `partition`. If they are exhaustive then, `exhaustivePartitions` may be True. +A `csvw:Column` or a `csvw-eo:ColumnGroup` can have a list of partitions in the field `partition`. If they are exhaustive then, `exhaustivePartitions` may be True. Example: Categorical column ```json { - "@type": "csvw-safe:Partition", - "csvw-safe:predicate": { + "@type": "csvw-eo:Partition", + "csvw-eo:predicate": { "partitionValue": "Biscoe" }, "maxLength": 300, @@ -140,8 +140,8 @@ Categorical column Continuous column ```json { - "@type": "csvw-safe:Partition", - "csvw-safe:predicate": { + "@type": "csvw-eo:Partition", + "csvw-eo:predicate": { "lowerBound": 100, "upperBound": 200, }, @@ -153,7 +153,7 @@ Continuous column ## JSON-LD Structure -CSVW-SAFE extends standard CSVW JSON-LD structures with additional properties and objects. -This image presents the base `csvw` json-ld structure on the left and the extended `csvw-safe`. +CSVW-EO extends standard CSVW JSON-LD structures with additional properties and objects. +This image presents the base `csvw` json-ld structure on the left and the extended `csvw-eo`. -![Overview](../images/csvw-safe_structure.png) \ No newline at end of file +![Overview](../images/csvw-eo_structure.png) \ No newline at end of file diff --git a/docs/vocabulary/dp_contributions.md b/docs/vocabulary/dp_contributions.md index 419641f..d43303f 100644 --- a/docs/vocabulary/dp_contributions.md +++ b/docs/vocabulary/dp_contributions.md @@ -1,6 +1,6 @@ # Differential Privacy Contributions -CSVW-SAFE defines metadata for Differential Privacy (DP) calibration. +CSVW-EO defines metadata for Differential Privacy (DP) calibration. These properties describe worst-case assumptions about how privacy units may contribute to datasets. @@ -22,7 +22,7 @@ Examples: Two datasets are considered neighbouring datasets if and only if all rows associated with one privacy unit are added or removed. -CSVW-SAFE currently assumes a single privacy unit per dataset. +CSVW-EO currently assumes a single privacy unit per dataset. | Property | Type | Meaning | Level | | ------------- | ------- | ----------------------------------------- | ------ | @@ -135,11 +135,11 @@ where: - $l_\infty$ = `maxContributions` (maximum number of rows contributed within one group) -CSVW-SAFE does not define $l_1$ as a separate metadata property because its interpretation depends on the query structure and grouping context. +CSVW-EO does not define $l_1$ as a separate metadata property because its interpretation depends on the query structure and grouping context. ## Contribution Levels -CSVW-SAFE supports multiple granularity levels for contribution metadata. +CSVW-EO supports multiple granularity levels for contribution metadata. | Level | Description | Privacy Risk | | ----------------- | ------------------------------------ | ------------ | diff --git a/docs/vocabulary/dummy_modeling.md b/docs/vocabulary/dummy_modeling.md index 4092b5a..2707220 100644 --- a/docs/vocabulary/dummy_modeling.md +++ b/docs/vocabulary/dummy_modeling.md @@ -1,6 +1,6 @@ # Dummy Modeling Properties -CSVW-SAFE defines properties useful for generating realistic dummy datasets. +CSVW-EO defines properties useful for generating realistic dummy datasets. These properties improve dummy data quality while remaining compatible with differential privacy workflows. @@ -93,7 +93,7 @@ Example: ## Public Keys -CSVW-SAFE can define known public domains. +CSVW-EO can define known public domains. | Property | Meaning | | ---------------- | --------------------------- | @@ -136,7 +136,7 @@ Partitions describe public regions of the domain. | Property | Meaning | | ---------------- | --------------------------- | -| `partition` | List of `csvw-safe:Partition` objects | +| `partition` | List of `csvw-eo:Partition` objects | | `exhaustivePartitions` | Whether partitions fully cover the domain | Examples: diff --git a/docs/vocabulary/examples.md b/docs/vocabulary/examples.md index f485a26..e9716a5 100644 --- a/docs/vocabulary/examples.md +++ b/docs/vocabulary/examples.md @@ -1,4 +1,4 @@ -# CSVW-SAFE Examples +# CSVW-EO Examples This section provides example metadata structures. @@ -30,8 +30,8 @@ This section provides example metadata structures. ```json { - "@type": "csvw-safe:Partition", - "csvw-safe:predicate": { + "@type": "csvw-eo:Partition", + "csvw-eo:predicate": { "month": "January" }, "maxContributions": 31 @@ -42,8 +42,8 @@ This section provides example metadata structures. ```json { - "@type": "csvw-safe:ColumnGroup", - "csvw-safe:columns": [ + "@type": "csvw-eo:ColumnGroup", + "csvw-eo:columns": [ "year", "month" ] @@ -84,13 +84,5 @@ This section provides example metadata structures. See: -- Penguin metadata example -- Example notebooks -- CSVW-SAFE library examples - -Repository examples demonstrate: - -- metadata generation -- validation -- dummy data generation -- DP workflows \ No newline at end of file +- Penguin metadata examples [here](https://github.com/dscc-admin-ch/csvw-eo/tree/main/csvw-eo-library/examples/metadata) +- Example notebook [here](https://github.com/dscc-admin-ch/csvw-eo/blob/main/csvw-eo-library/examples/Use-Library.ipynb) diff --git a/docs/vocabulary/framework.md b/docs/vocabulary/framework.md index d6675de..e00f63b 100644 --- a/docs/vocabulary/framework.md +++ b/docs/vocabulary/framework.md @@ -1,19 +1,19 @@ -# CSVW-SAFE Framework +# CSVW-EO Framework -CSVW-SAFE consists of vocabulary definitions, validation rules, and Python tooling. +CSVW-EO consists of vocabulary definitions, validation rules, and Python tooling. ## Components | File | Purpose | |---|---| -| `csvw-safe-vocab.ttl` | RDF vocabulary | -| `csvw-safe-context.jsonld` | JSON-LD context | -| `csvw-safe-constraints.ttl` | SHACL constraints | -| `csvw-safe-library` | Python tooling | +| `csvw-eo-vocab.ttl` | RDF vocabulary | +| `csvw-eo-context.jsonld` | JSON-LD context | +| `csvw-eo-constraints.ttl` | SHACL constraints | +| `csvw-eo-library` | Python tooling | ## Validation Layers -CSVW-SAFE metadata may be validated using: +CSVW-EO metadata may be validated using: ### Pydantic Validation @@ -41,7 +41,7 @@ Checks: ## Python Library -The `csvw-safe-library` provides: +The `csvw-eo-library` provides: - metadata generation - dummy data generation @@ -54,7 +54,7 @@ The `csvw-safe-library` provides: ## Differential Privacy Integrations -CSVW-SAFE can be converted to: +CSVW-EO can be converted to: - OpenDP contexts - SmartNoise SQL metadata diff --git a/docs/vocabulary/overview.md b/docs/vocabulary/overview.md index e97949d..9626666 100644 --- a/docs/vocabulary/overview.md +++ b/docs/vocabulary/overview.md @@ -1,6 +1,6 @@ -# CSVW-SAFE Overview +# CSVW-EO Overview -CSVW-SAFE extends the W3C [CSV on the Web (CSVW)](https://www.w3.org/TR/tabular-data-model/) standard with privacy-safe metadata for: +CSVW-EO extends the W3C [CSV on the Web (CSVW)](https://www.w3.org/TR/tabular-data-model/) standard with privacy-safe metadata for: - Differential Privacy (DP) - Dummy data generation @@ -8,9 +8,9 @@ CSVW-SAFE extends the W3C [CSV on the Web (CSVW)](https://www.w3.org/TR/tabular- - Public partition definitions - Safe schema publication -![Overview](../images/csvw-safe_structure.png) +![Overview](../images/csvw-eo_structure.png) -CSVW-SAFE allows organizations to publish assumptions and guarantees about datasets without exposing sensitive underlying records. +CSVW-EO allows organizations to publish assumptions and guarantees about datasets without exposing sensitive underlying records. These assumptions may include: @@ -29,7 +29,7 @@ These assumptions may include: ## Main Concepts -CSVW-SAFE extends CSVW with: +CSVW-EO extends CSVW with: | Concept | Purpose | |---|---| @@ -43,7 +43,7 @@ CSVW-SAFE extends CSVW with: | File | Purpose | |---|---| -| `csvw-safe-vocab.ttl` | RDF vocabulary | -| `csvw-safe-context.jsonld` | JSON-LD context | -| `csvw-safe-constraints.ttl` | SHACL validation | -| `csvw-safe-library` | Python tooling | +| `csvw-eo-vocab.ttl` | RDF vocabulary | +| `csvw-eo-context.jsonld` | JSON-LD context | +| `csvw-eo-constraints.ttl` | SHACL validation | +| `csvw-eo-library` | Python tooling | diff --git a/documentation/dp_libraries.md b/documentation/dp_libraries.md index 19c5f19..70362da 100644 --- a/documentation/dp_libraries.md +++ b/documentation/dp_libraries.md @@ -28,7 +28,7 @@ ## Cross-Library DP Vocabulary Mapping -| Type | CSVW-SAFE Vocabulary | OpenDP | Smartnoise-SQL | Privacy on Beam | PipelineDP | Qrlew | Tumult | +| Type | CSVW-EO Vocabulary | OpenDP | Smartnoise-SQL | Privacy on Beam | PipelineDP | Qrlew | Tumult | |-----------|----------------------|------------------------------------------------|-----------------|-----------------|---------------------|------------------|--------------| | Table | maxContributions | dp.unit_of(contributions=1) | max_ids | | max_contribution | max_multiplicity | MaxRowsPerID | | Table | publicLength | margins=[dp.polars.Margin(invariant="length")] | n_row | | | size | | diff --git a/images/csvw-eo_structure.png b/images/csvw-eo_structure.png new file mode 100644 index 0000000..8edbaae Binary files /dev/null and b/images/csvw-eo_structure.png differ diff --git a/images/csvw-safe_structure.png b/images/csvw-safe_structure.png deleted file mode 100644 index 4b8a82d..0000000 Binary files a/images/csvw-safe_structure.png and /dev/null differ diff --git a/manual_penguin_metadata.jsonld b/manual_penguin_metadata.jsonld index 8a73e36..06f3308 100644 --- a/manual_penguin_metadata.jsonld +++ b/manual_penguin_metadata.jsonld @@ -1,7 +1,7 @@ { "@context": [ "http://www.w3.org/ns/csvw", - "csvw-safe-context.jsonld" + "csvw-eo-context.jsonld" ], "@type": "Table", "maxContributions": 1, diff --git a/mkdocs.yml b/mkdocs.yml index 131d0be..9f53cc5 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,6 +1,6 @@ -site_name: CSVW-SAFE -site_description: CSVW-SAFE vocabulary and Python library -site_url: https://dscc-admin-ch.github.io/csvw-safe-docs/ +site_name: CSVW-EO +site_description: CSVW-EO vocabulary and Python library +site_url: https://dscc-admin-ch.github.io/csvw-eo-docs/ theme: name: material @@ -11,7 +11,7 @@ plugins: handlers: python: paths: - - csvw-safe-library/src + - csvw-eo-library/src options: docstring_style: numpy show_source: true @@ -43,6 +43,7 @@ nav: - Workflows: library/workflows.md - Metadata Generation: library/metadata_generation.md - Dummy Generation: library/dummy_generation.md + - Pydantic Model: library/table_metadata.md - Validation: library/validation.md - Integrations: library/integration.md diff --git a/site/404.html b/site/404.html index 18bdf33..c555c76 100644 --- a/site/404.html +++ b/site/404.html @@ -6,7 +6,7 @@ - + @@ -16,16 +16,16 @@ - + - CSVW-SAFE + CSVW-EO - + @@ -44,9 +44,9 @@ - + - + @@ -75,7 +75,7 @@