Skip to main content

A tool to enrich any OCDM compliant Knowledge Graph, finding new identifiers and deduplicating entities

Project description

Tests Pyright Ruff Coverage REUSE status

OC GraphEnricher

OC GraphEnricher enriches OpenCitations Data Model (OCDM) compliant knowledge graphs by finding missing identifiers and deduplicating entities.

Documentation: https://opencitations.github.io/oc_graphenricher/

Quick start

pip install oc-graphenricher
from oc_ocdm.graph.graph_set import GraphSet
from oc_ocdm.reader import Reader
from rdflib import Graph

from oc_graphenricher.enricher import GraphEnricher
from oc_graphenricher.deduplication import GraphDeduplicator
from oc_graphenricher.storage import single_file_storage

graph = Graph().parse("data/input.nt", format="nt11")

reader = Reader()
graph_set = GraphSet(base_iri="https://w3id.org/oc/meta/")
reader.import_entities_from_graph(
    graph_set,
    graph,
    enable_validation=False,
    resp_agent="https://w3id.org/oc/meta/prov/pa/2",
)

GraphEnricher(
    graph_set=graph_set,
    storage=single_file_storage(
        graph_path="enriched.json",
        provenance_path="provenance.json",
    ),
).enrich()
GraphDeduplicator(
    graph_set=graph_set,
    storage=single_file_storage(
        graph_path="deduplicated.json",
        provenance_path="provenance.json",
    ),
).deduplicate_and_save()

By default, GraphDeduplicator does not merge contributor roles only because author names are similar. To enable that opt-in behavior, pass merge_similar_named_contributors=True.

Use deduplicate() instead of deduplicate_and_save() when another application needs to manage storage or provenance output itself. Use preferred_survivors with a set of entity URIs to keep selected entities when duplicate clusters are merged.

For configuration options and usage details, see the documentation.

License

Distributed under the ISC License. See LICENSE.

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

oc_graphenricher-2.0.0.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

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

oc_graphenricher-2.0.0-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file oc_graphenricher-2.0.0.tar.gz.

File metadata

  • Download URL: oc_graphenricher-2.0.0.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for oc_graphenricher-2.0.0.tar.gz
Algorithm Hash digest
SHA256 842387861edecddc8d72338ba5cb80f9b37161da26a02a2c9be1247da9c6c655
MD5 c472fa9286c91f522cfaa4538d5dd8c4
BLAKE2b-256 957246cef6da63be62fbf10c76d9fc14a0106f2a794a1c55e3859e2a6f5d5355

See more details on using hashes here.

File details

Details for the file oc_graphenricher-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: oc_graphenricher-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for oc_graphenricher-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 15a949b3317e089021737328014a5ff73dfc124736410d60698ff4252d5ed56b
MD5 0b4a35b297399b78e4c5644f5dbd7d44
BLAKE2b-256 f51f45d26a119feac2a2fc8367b47c4942c756be0fa74edcf30bb1b9ac6a4f6f

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