Knowledge Integration Framework
KIF is a Python framework for knowledge integration from IBM Research.
It is based on Wikidata and licensed under the open-source Apache-2.0 license.
First time here? Check out the tutorial.
Looking for the sources? See the GitHub repository.
Hello world!
Install KIF using pip:
$ pip install kif-lib
Use KIF to query Wikidata:
>>> from kif_lib import Store
>>> from kif_lib.vocabulary import wd
>>> kb = Store('wikidata')
>>> next(kb.filter(subject=wd.Alan_Turing, property=wd.doctoral_advisor))
Statement(Item(IRI('http://www.wikidata.org/entity/Q7251')), ValueSnak(...))
Or, via KIF CLI (the command-line interface):
$ pip install kif-lib[cli] # KIF CLI is an optional dependency
$ kif filter --subject=wd.Alan_Turing --property=wd.doctoral_advisor
(Statement (Item Alan Turing) (ValueSnak (Property doctoral advisor) (Item Alonzo Church)))
KIF can also be used query other knowledge sources. Here is a similar query over DBpedia (notice the -s dbpedia switch):
$ kif filter -s dbpedia --subject=db.Alan_Turing --property=wd.doctoral_advisor
(Statement (Item dbr:Alan_Turing) (ValueSnak (Property dbo:doctoralAdvisor) (Item dbr:Alonzo_Church)))
The result is a stream of Wikidata-like statements containing DBpedia entities.
KIF in a nutshell
KIF is a knowledge integration framework based on Wikidata. The idea behind it is to use Wikidata to standardize the syntax and (whenever possible) the vocabulary of the integrated knowledge sources. Users can then query the sources through filter patterns described in terms of the Wikidata data model.
The integration done by KIF is virtual in the sense that syntax and vocabulary translations happen dynamically (at query time) and are guided by user-provided mappings. KIF comes with built-in mappings for Wikidata, DBpedia, FactGrid, PubChem, and UniProt, among others. New mappings can be added programmatically.
Highlights
-
KIF allows one to query knowledge sources as if they were Wikidata.
-
KIF queries are written as simple, high-level filters using entities of the Wikidata data model, such as items, properties, quantities, snaks, statements, etc.
-
KIF can be used to query Wikidata itself or other knowledge sources, provided proper mappings are given.
-
KIF can run queries over local RDF data using RDFLib, Apache Jena, QLever, or RDFox.
-
KIF has full support for Python's asyncio. KIF async API can be used run queries asynchronously, without blocking waiting on their results.
Installation
To install KIF, use:
$ pip install kif-lib
To include KIF CLI, use:
$ pip install kif-lib[cli]
To include all extras, use:
$ pip install kif-lib[extra]
Documentation
KIF documentation is available at https://ibm.github.io/kif/.
For a primer on KIF, see the tutorial.
Dependencies
Required:
- httpx - HTTP support.
- lark - Parsing.
- more_itertools - Extra itertools.
- networkx - Graph algorithms.
- rdflib - RDF support.
- typing-extensions - Typing backports.
KIF CLI (optional):
- click - Option parsing. (Optional, with
kif-lib[cli]) - rich - Rich terminal support. (Optional, with
kif-lib[cli])
Extra (optional):
- graphviz - Graph drawing. (Optional, with
kif-lib[extra]) - jpype1 - Java support. (Optional, with
kif-lib[extra]) - pandas - CSV/DataFrame support. (Optional, with
kif-lib[extra]) - psutil - Process information. (Optional, with
kif-lib[extra])
Citation
Guilherme Lima, João M. B. Rodrigues, Marcelo Machado, Elton Soares, Sandro R. Fiorini, Raphael Thiago, Leonardo G. Azevedo, Viviane T. da Silva, Renato Cerqueira. 2024. "KIF: A Wikidata-Based Framework for Integrating Heterogeneous Knowledge Sources", arXiv:2403.10304, 2024.
Metadata
Release files for kif-lib 0.13.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kif_lib-0.13.0.tar.gz | 723.2 kB | Without provenance | Details for kif_lib-0.13.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kif_lib-0.13.0-py3-none-any.whl | Python 3 | none | any | Details for kif_lib-0.13.0-py3-none-any.whl |
Total release size: 1.5 MB
Release files / kif_lib-0.13.0.tar.gz
| Download URL | kif_lib-0.13.0.tar.gz |
|---|---|
| Size | 723.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fd9237c66e3318b3c342c7cacb51f93dbcbc4cfffe77718ce8af80dc6ed53b72
|
|
BLAKE2b-256 checksum How to use checksums |
043c179ebf6dc3d53ff673741dfbdc59f0301ecf26d86468d825a6e65b91daf7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / kif_lib-0.13.0-py3-none-any.whl
| Download URL | kif_lib-0.13.0-py3-none-any.whl |
|---|---|
| Size | 801.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d3666dd359f3a0229135519d0e92d584d7149168bcdcbe6ca766c12397eea6ba
|
|
BLAKE2b-256 checksum How to use checksums |
ade9e34ddc9e0c9f6f03f8e8a5b8fcd29abe9a5cba59ba7a5ec4525cfb48aeb0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for kif-lib 0.13.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.