Skip to main content

ProvSense is a Python library for managing knowledge graph provenance. It enables efficient comparison of files, tracking changes, and enforcing provenance rules to ensure data integrity and traceability. Ideal for researchers and developers, ProvSense promotes transparency and accountability in data-driven workflows.

Project description

ProvSense

ProvSense is a Python library for managing knowledge graph provenance. It enables efficient comparison of files, tracking changes, and enforcing provenance rules to ensure data integrity and traceability. Ideal for researchers and developers, ProvSense promotes transparency and accountability in data-driven workflows.

Installation

Install this package via :

pip install ProvSense

Or get the newest development version via:

pip install git+https://github.com/sensein/ProvSense/.git

Usage

For example files, see example directory.

1️⃣ Compare Two Knowledge Graph Strings

You can compare two JSON-LD/Turtle/N-Triples formatted knowledge graphs as strings.

from ProvSense.app import compare_items

# KG string comparison
src = """{ "@context": { "ex": "http://example.org/" }, "@id": "ex:Person1", "@type": "ex:Person", "ex:name": "Alice" }"""

dst = """{ "@context": { "ex": "http://example.org/" }, "@id": "ex:Person1", "@type": "ex:Person", "ex:name": "BoB" }"""

# Compare and print results
print(compare_items(src, dst))

Output:

[
    {'subject': 'http://example.org/Person1',
  'property': 'http://example.org/name',
  'src_value': 'Alice',
  'dst_value': 'BoB'},
 {'subject': 'http://example.org/Person1',
  'property': 'http://example.org/name',
  'src_value': 'Alice',
  'dst_value': 'BoB'}
]

2️⃣ Compare Two Knowledge Graph Files

Pass file paths to compare JSON-LD, TTL, or NT files.

from ProvSense.app import compare_items
print(compare_items("test_src.jsonld", "test_dst.jsonld"))

Output:

[
    {'subject': 'urn:uuid:550e8400-e29b-41d4-a716-446655440000',
  'property': 'http://example.org/worksAt',
  'src_value': 'http://example.org/Company',
  'dst_value': 'http://example.org/CompanyY'},
 {'subject': 'urn:uuid:550e8400-e29b-41d4-a716-446655440000',
  'property': 'http://example.org/worksAt',
  'src_value': 'http://example.org/Company',
  'dst_value': 'http://example.org/CompanyY'},
 {'subject': 'urn:uuid:550e8400-e29b-41d4-a716-446655440000',
  'property': 'http://example.org/location',
  'src_value': None,
  'dst_value': 'New York'}
]

3️⃣ Compare Two Directories

Compare all JSON-LD, TTL, and NT files in two folders recursively.

Note: The source and destination folders must contain files with matching filenames for a valid comparison.

from ProvSense.app import compare_items
print(compare_items("src", "dst"))

Output:

{'test_file.jsonld': [{'subject': 'urn:uuid:550e8400-e29b-41d4-a716-446655440000',
   'property': 'http://example.org/worksAt',
   'src_value': 'http://example.org/CompanyX',
   'dst_value': 'http://example.org/CompanyY'},
  {'subject': 'urn:uuid:550e8400-e29b-41d4-a716-446655440000',
   'property': 'http://example.org/location',
   'src_value': None,
   'dst_value': 'New York'},
  {'subject': 'urn:uuid:550e8400-e29b-41d4-a716-446655440000',
   'property': 'http://example.org/worksAt',
   'src_value': 'http://example.org/CompanyX',
   'dst_value': 'http://example.org/CompanyY'}],
 'test_file_b.jsonld': [{'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/affiliation',
   'src_value': 'http://dbpedia.org/resource/Princeton_University',
   'dst_value': 'http://dbpedia.org/resource/ETH_Zurich'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/affiliation',
   'src_value': 'http://dbpedia.org/resource/Princeton_University',
   'dst_value': 'http://dbpedia.org/resource/University_of_Berlin'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/affiliation',
   'src_value': 'http://dbpedia.org/resource/ETH_Zurich',
   'dst_value': 'http://dbpedia.org/resource/Princeton_University'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/affiliation',
   'src_value': 'http://dbpedia.org/resource/ETH_Zurich',
   'dst_value': 'http://dbpedia.org/resource/University_of_Berlin'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/nationality',
   'src_value': 'http://dbpedia.org/resource/Switzerland',
   'dst_value': 'http://dbpedia.org/resource/Germany'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/nationality',
   'src_value': 'http://dbpedia.org/resource/Switzerland',
   'dst_value': 'http://dbpedia.org/resource/United_States'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/knowsAbout',
   'src_value': 'http://dbpedia.org/resource/Quantum_mechanics',
   'dst_value': 'http://dbpedia.org/resource/Brownian_motion'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/knowsAbout',
   'src_value': 'http://dbpedia.org/resource/Quantum_mechanics',
   'dst_value': 'http://dbpedia.org/resource/Theory_of_relativity'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/affiliation',
   'src_value': 'http://dbpedia.org/resource/University_of_Berlin',
   'dst_value': 'http://dbpedia.org/resource/Princeton_University'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/affiliation',
   'src_value': 'http://dbpedia.org/resource/University_of_Berlin',
   'dst_value': 'http://dbpedia.org/resource/ETH_Zurich'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/sameAs',
   'src_value': 'https://www.wikidata.org/wiki/Q937',
   'dst_value': 'https://en.wikipedia.org/wiki/Albert_Einstein'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/nationality',
   'src_value': 'http://dbpedia.org/resource/Germany',
   'dst_value': 'http://dbpedia.org/resource/Switzerland'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/nationality',
   'src_value': 'http://dbpedia.org/resource/Germany',
   'dst_value': 'http://dbpedia.org/resource/United_States'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/knowsAbout',
   'src_value': 'http://dbpedia.org/resource/Brownian_motion',
   'dst_value': 'http://dbpedia.org/resource/Quantum_mechanics'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/knowsAbout',
   'src_value': 'http://dbpedia.org/resource/Brownian_motion',
   'dst_value': 'http://dbpedia.org/resource/Theory_of_relativity'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/alternateName',
   'src_value': 'Einstein',
   'dst_value': 'Prof. Einstein'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/alternateName',
   'src_value': 'Prof. Einstein',
   'dst_value': 'Einstein'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/knowsAbout',
   'src_value': 'http://dbpedia.org/resource/Theory_of_relativity',
   'dst_value': 'http://dbpedia.org/resource/Quantum_mechanics'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/knowsAbout',
   'src_value': 'http://dbpedia.org/resource/Theory_of_relativity',
   'dst_value': 'http://dbpedia.org/resource/Brownian_motion'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/nationality',
   'src_value': 'http://dbpedia.org/resource/United_States',
   'dst_value': 'http://dbpedia.org/resource/Switzerland'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/nationality',
   'src_value': 'http://dbpedia.org/resource/United_States',
   'dst_value': 'http://dbpedia.org/resource/Germany'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/sameAs',
   'src_value': 'https://en.wikipedia.org/wiki/Albert_Einstein',
   'dst_value': 'https://www.wikidata.org/wiki/Q937'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/affiliation',
   'src_value': 'http://dbpedia.org/resource/ETH_Zurich',
   'dst_value': 'http://dbpedia.org/resource/Princeton_University'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/affiliation',
   'src_value': 'http://dbpedia.org/resource/University_of_Berlin',
   'dst_value': 'http://dbpedia.org/resource/Princeton_University'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/affiliation',
   'src_value': 'http://dbpedia.org/resource/Princeton_University',
   'dst_value': 'http://dbpedia.org/resource/ETH_Zurich'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/affiliation',
   'src_value': 'http://dbpedia.org/resource/University_of_Berlin',
   'dst_value': 'http://dbpedia.org/resource/ETH_Zurich'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/nationality',
   'src_value': 'http://dbpedia.org/resource/Germany',
   'dst_value': 'http://dbpedia.org/resource/Switzerland'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/nationality',
   'src_value': 'http://dbpedia.org/resource/United_States',
   'dst_value': 'http://dbpedia.org/resource/Switzerland'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/knowsAbout',
   'src_value': 'http://dbpedia.org/resource/Brownian_motion',
   'dst_value': 'http://dbpedia.org/resource/Quantum_mechanics'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/knowsAbout',
   'src_value': 'http://dbpedia.org/resource/Theory_of_relativity',
   'dst_value': 'http://dbpedia.org/resource/Quantum_mechanics'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/affiliation',
   'src_value': 'http://dbpedia.org/resource/Princeton_University',
   'dst_value': 'http://dbpedia.org/resource/University_of_Berlin'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/affiliation',
   'src_value': 'http://dbpedia.org/resource/ETH_Zurich',
   'dst_value': 'http://dbpedia.org/resource/University_of_Berlin'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/sameAs',
   'src_value': 'https://en.wikipedia.org/wiki/Albert_Einstein',
   'dst_value': 'https://www.wikidata.org/wiki/Q937'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/nationality',
   'src_value': 'http://dbpedia.org/resource/Switzerland',
   'dst_value': 'http://dbpedia.org/resource/Germany'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/nationality',
   'src_value': 'http://dbpedia.org/resource/United_States',
   'dst_value': 'http://dbpedia.org/resource/Germany'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/knowsAbout',
   'src_value': 'http://dbpedia.org/resource/Quantum_mechanics',
   'dst_value': 'http://dbpedia.org/resource/Brownian_motion'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/knowsAbout',
   'src_value': 'http://dbpedia.org/resource/Theory_of_relativity',
   'dst_value': 'http://dbpedia.org/resource/Brownian_motion'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/alternateName',
   'src_value': 'Prof. Einstein',
   'dst_value': 'Einstein'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/alternateName',
   'src_value': 'Einstein',
   'dst_value': 'Prof. Einstein'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/knowsAbout',
   'src_value': 'http://dbpedia.org/resource/Quantum_mechanics',
   'dst_value': 'http://dbpedia.org/resource/Theory_of_relativity'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/knowsAbout',
   'src_value': 'http://dbpedia.org/resource/Brownian_motion',
   'dst_value': 'http://dbpedia.org/resource/Theory_of_relativity'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/nationality',
   'src_value': 'http://dbpedia.org/resource/Switzerland',
   'dst_value': 'http://dbpedia.org/resource/United_States'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/nationality',
   'src_value': 'http://dbpedia.org/resource/Germany',
   'dst_value': 'http://dbpedia.org/resource/United_States'},
  {'subject': 'http://dbpedia.org/resource/Albert_Einstein',
   'property': 'http://schema.org/sameAs',
   'src_value': 'https://www.wikidata.org/wiki/Q937',
   'dst_value': 'https://en.wikipedia.org/wiki/Albert_Einstein'},
  {'subject': 'http://dbpedia.org/resource/Brownian_motion',
   'property': 'http://schema.org/name',
   'src_value': 'Brownian',
   'dst_value': 'Brownian Motion'},
  {'subject': 'http://dbpedia.org/resource/Brownian_motion',
   'property': 'http://schema.org/name',
   'src_value': 'Brownian',
   'dst_value': 'Brownian Motion'},
  {'subject': 'http://dbpedia.org/resource/Theory_of_relativity',
   'property': 'http://schema.org/name',
   'src_value': 'Relativity',
   'dst_value': 'Theory of Relativity'},
  {'subject': 'http://dbpedia.org/resource/Theory_of_relativity',
   'property': 'http://schema.org/name',
   'src_value': 'Relativity',
   'dst_value': 'Theory of Relativity'}]}

Running Tests

To run all tests in the project:

python -m unittest discover src/tests

To run a specific test file:

python -m unittest src/tests/test_ttl_conversion.py

To run tests with verbose output:

python -m unittest -v src/tests/test_ttl_conversion.py

To do:

  • Add LLM for advanced comparison

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

provsense-1.0.2.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

provsense-1.0.2-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file provsense-1.0.2.tar.gz.

File metadata

  • Download URL: provsense-1.0.2.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.7 Darwin/23.6.0

File hashes

Hashes for provsense-1.0.2.tar.gz
Algorithm Hash digest
SHA256 4ef43c7b30bfab89c71ca566772ba7815054d6c471f39ecf819ee3d15a06732b
MD5 8bff1abf47b94aac60f8b0ed6b558c7d
BLAKE2b-256 86de1380ea32f89b94127c891846a5b67374e7909516ffdfb1abfbc18143db23

See more details on using hashes here.

File details

Details for the file provsense-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: provsense-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.7 Darwin/23.6.0

File hashes

Hashes for provsense-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 71472789607ee7602fcbbf31dbae387ffcc933bca2863ef8a91c3e4b1b539b27
MD5 b9b2f474809102fa222fecf00888b221
BLAKE2b-256 d34f28b1f5b25e150a4a8fbfd10cba98135d8daf3273373671720b5023500b3a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page