Skip to main content

A concurrent client to reconcile entities against wikidata.

Project description

Wikibase Reconcile

An multi-threaded client to reconcile against wikidata.

This project is inspired by reconciler. If you look for stable and mature software, I recommend using the excellent package reconciler.

Features

  • Concurrent requests to wikidata reconiliation API
  • Makes atomic requests and is more robust when the API returns errors
  • Takes a pandas dataframe as input and also as output
  • User has rather high degree of control (but also needs more code)

Installation

pip install wikibase-reconcile

Usage

from wikibase_reconcile import Client

client = Client()

# Initialize some simple test data
characters = [
    {"type": "Q15632617", "query": "Marge Simpson"},
    {"type": "Q15632617", "query": "Homer Simpson"},
    {"type": "Q15632617", "query": "Bart Simpson"},
    {"type": "Q15632617", "query": "Lisa Simpson"},
    {"type": "Q15632617", "query": "Maggie Simpson"},
    {"type": "Q15632617", "query": "Abraham Simpson"},
    {"type": "Q15632617", "query": "Apu Nahasapeemapetilon"},
    {"type": "Q15632617", "query": "Barney Gumble"}
]

df = pd.DataFrame(characters)

# reconcile each search query against the type "Fictional Human"
results = client.reconcile(df)

# Turn results into a dataframe, keep only the top result
df_reconciled = client.results_to_pandas(results)

Fallback Logic

You can specify an additional fallback search string in case the first attempt did not yield any result:

query = {"type": "Q15632617", "query": "Marge Simpson", "fallback_query": "Marjorie Bouvier"}

One use case for fallback queries are lemmatized versions of the original query.

If this still yields no results, then the reconciler will attempt to match the first part of the query, by splitting the query at every hyphen character (-) and taking the first part. This logic is likely to change in future versions.

The final fallback is to ignore the type and try to reconcile against any type. The default API server (https://wikidata.reconci.link/) will then match against the generic entity type (Q35120).

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

wikibase_reconcile-0.2.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

wikibase_reconcile-0.2.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file wikibase_reconcile-0.2.0.tar.gz.

File metadata

  • Download URL: wikibase_reconcile-0.2.0.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for wikibase_reconcile-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0825e0fbb89730f719bdbaf98bd3afe8541c4c8f3d3ceb6db9d4a409f08d446a
MD5 99df57948c10fbbcc218aa1bef543dc5
BLAKE2b-256 1b14477cbcfaa3003d0d47e32c084525827b95e196030c2f1075a69fdc1bca6e

See more details on using hashes here.

File details

Details for the file wikibase_reconcile-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for wikibase_reconcile-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e35de98d0634e37af9c629952040ffc23a79b43ff8f5fd28544d661a0d35c6b2
MD5 13f41b4884cbb11bcd91b8abc2340799
BLAKE2b-256 c2418ca1c2df95cb42c9fc8111d5b390a17809aa772931c2ee5ae48a454437a5

See more details on using hashes here.

Supported by

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