Library to annotate RDF or ShEx containing Wikidata URIs with readable labels
Project description
wLighter
wLighter is a Python library to annotate ShEx or RDF files containing Wikidata entities and properties.
Wikidata identifies properties witn an ID such as "PXXX" and entities with IDs such as "QXXX", where XXX is a number with no relation with the concept represented by the ID. This causes that text files containing many Wikidata IDs are quite hard to understand.
wLighter is a simple library built on top of the Wikidata API. It expect to receive RDF or ShEx content where some Wikidata URIs are used. It returns the same content with annotations (comments) in which each Wikidata ID is associated to its label.
You can specify in which language you prefer the labels. wLighter will try to get the label for your preferred language(s), or get the English one in case some ID has no label in your selected language.
When working with ShEx, you can also select if you prefer to generate inline comments using '# QXX --> Example' or rdfs inline annotation such as '// rdfs:comment "QXX --> Example"'.
You can also choose to provide your input or get your output via string or reading some file's content.
The input formats currently supported are ShExC and Turtle.
Please, contact the author or feel free to add an issue to this repository if you find a bug or have some feature request.
Instalation
You can install wLighter using pip. Execute the following command:
$ pip install wlighter
If you prefer to use wLighter by source with git clone, ensure you execute it in an enviroment with the dependencies listed in requirements.txt. You can install those dependencies by using the following command:
$ pip install -r requirements.txt
Example code
The following example code takes a ShEx file placed in wiki_test_file.shex and annotates it generating inline rdfs:comments. The result is returned as a string. The preferred language for the labels is Spanish. In case there is not a label in Spanish for a given element, then wLighter will use the French one. If French is missing too, then the English one.
from wlighter import WLighter, SHEXC_FORMAT
target_file = "wiki_test_file.shex"
wlig = WLighter(file_input=target_file,
format=SHEXC_FORMAT,
languages=["es", "fr"],
generate_rdfs_comments=True)
result = wlig.annotate_all(string_return=True)
print(result)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wlighter-1.0.2.tar.gz.
File metadata
- Download URL: wlighter-1.0.2.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b77b93e318306f15879baa6f453b13055518a6a3bd2e2bd9bfe48c5dd9312d3e
|
|
| MD5 |
8e417b51914da8b65c9e6d00eb79a3d2
|
|
| BLAKE2b-256 |
373ed45c63e9bcc025e3ac78241e49250516d7456bf5802ff90b39b39ab2c749
|
Provenance
The following attestation bundles were made for wlighter-1.0.2.tar.gz:
Publisher:
publish.yml on DaniFdezAlvarez/wLighter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wlighter-1.0.2.tar.gz -
Subject digest:
b77b93e318306f15879baa6f453b13055518a6a3bd2e2bd9bfe48c5dd9312d3e - Sigstore transparency entry: 1840433849
- Sigstore integration time:
-
Permalink:
DaniFdezAlvarez/wLighter@428d442d2c30adc5f41f2e00ba75248a6510d0c8 -
Branch / Tag:
refs/tags/1.0.2 - Owner: https://github.com/DaniFdezAlvarez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@428d442d2c30adc5f41f2e00ba75248a6510d0c8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file wlighter-1.0.2-py3-none-any.whl.
File metadata
- Download URL: wlighter-1.0.2-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35fda155265100458127180093b06da9919724128111743dd1a80c3e58bd80f9
|
|
| MD5 |
6c9da925d7481048d18ab249d4ddfaa3
|
|
| BLAKE2b-256 |
15760aaf784fa7578b548a7062592aedb55c579388928b672f19ea6edaf5de27
|
Provenance
The following attestation bundles were made for wlighter-1.0.2-py3-none-any.whl:
Publisher:
publish.yml on DaniFdezAlvarez/wLighter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wlighter-1.0.2-py3-none-any.whl -
Subject digest:
35fda155265100458127180093b06da9919724128111743dd1a80c3e58bd80f9 - Sigstore transparency entry: 1840433965
- Sigstore integration time:
-
Permalink:
DaniFdezAlvarez/wLighter@428d442d2c30adc5f41f2e00ba75248a6510d0c8 -
Branch / Tag:
refs/tags/1.0.2 - Owner: https://github.com/DaniFdezAlvarez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@428d442d2c30adc5f41f2e00ba75248a6510d0c8 -
Trigger Event:
release
-
Statement type: