Name | kif-lib JSON |
Version |
0.11.0
JSON |
| download |
home_page | https://github.com/IBM/kif |
Summary | A knowledge integration framework based on Wikidata |
upload_time | 2025-07-15 20:10:36 |
maintainer | None |
docs_url | None |
author | IBM |
requires_python | >=3.9 |
license | Apache-2.0 |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
|
<img src="https://raw.githubusercontent.com/IBM/kif/refs/heads/main/docs/_static/kif-boxed.svg" width="96">
# Knowledge Integration Framework
KIF is a knowledge integration framework from [IBM
Research](https://research.ibm.com/).
It is based on [Wikidata](https://www.wikidata.org/) and licensed under the
[Apache-2.0 license](./LICENSE).
First time here? Check out the [quickstart
guide](https://ibm.github.io/kif/quickstart.html).
## Highlights
* KIF is an interface 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](https://www.wikidata.org/wiki/Wikidata:Data_model).
* KIF can be used to query Wikidata itself or other knowledge sources,
provided proper mappings are given.
* KIF comes with built-in mappings for [DBpedia](https://www.dbpedia.org/)
and [PubChem RDF](https://pubchem.ncbi.nlm.nih.gov/docs/rdf). Other
mappings can be added programmatically.
* KIF has full support for
[asyncio](https://docs.python.org/3/library/asyncio.html). KIF async API
can be used run queries asynchronously, without blocking waiting on their
results.
## Installation
Latest release:
```shell
$ pip install kif-lib
```
Development version:
```shell
$ pip install kif-lib@git+https://github.com/IBM/kif.git
```
## Documentation
See [documentation](https://ibm.github.io/kif/) and [examples](./examples).
### Hello world!
<hr/>
#### (1)
Gets from [Wikidata](https://www.wikidata.org/) all statements with property
[shares border with (P47)](http://www.wikidata.org/entity/P47) and value
[Brazil (Q155)](http://www.wikidata.org/entity/Q155).
Using the `kif` command-line utility:
```shell
kif filter -s wdqs --property=wd.shares_border_with --value='wd.Q(155)'
```
> (**Statement** (**Item** [Argentina](http://www.wikidata.org/entity/Q414)) (**ValueSnak** (**Property** [shares border with](http://www.wikidata.org/entity/P47)) (**Item** [Brazil](http://www.wikidata.org/entity/Q155)))) <br/>
> (**Statement** (**Item** [Peru](http://www.wikidata.org/entity/Q419)) (**ValueSnak** (**Property** [shares border with](http://www.wikidata.org/entity/P47)) (**Item** [Brazil](http://www.wikidata.org/entity/Q155)))) <br/>
> (**Statement** (**Item** [Paraguay](http://www.wikidata.org/entity/Q733)) (**ValueSnak** (**Property** [shares border with](http://www.wikidata.org/entity/P47)) (**Item** [Brazil](http://www.wikidata.org/entity/Q155)))) <br/>
> ⋮
Using the KIF API:
```python
from kif_lib import * # import the KIF namespace
from kif_lib.vocabulary import wd # import the Wikidata vocabulary module
# Create a SPARQL store loaded with Wikidata mappings and optimized for WDQS.
kb = Store('wdqs', 'https://query.wikidata.org/sparql')
# Filter all statements with the given property and value.
for stmt in kb.filter(property=wd.shares_border_with, value=wd.Q(155)):
print(stmt)
```
<hr/>
#### (2)
Gets from [Wikidata](https://www.wikidata.org/) and [PubChem
RDF](https://qlever.cs.uni-freiburg.de/api/pubchem) the IRI and molecular
mass of all chemicals whose formula is H₂O.
Using the `kif` command-line utility:
```shell
$ kif filter -s wdqs -s pubchem-sparql --select sv --subject='wd.chemical_formula("H₂O")' --property=wd.mass
```
> (**Item** [hydrogen tritium oxide](http://www.wikidata.org/entity/Q106010186)) 20.01878893 [dalton](http://www.wikidata.org/entity/Q483261) <br/>
> (**Item** [oxygen-15 atom](http://rdf.ncbi.nlm.nih.gov/pubchem/compound/CID10129877)) 17.0187 [dalton](http://www.wikidata.org/entity/Q483261) <br/>
> (**Item** [diprotium oxide](http://www.wikidata.org/entity/Q106010185)) 18.010564684 [dalton](http://www.wikidata.org/entity/Q483261) <br/>
> ⋮
Using the KIF API:
```python
# Create a mixer store combining:
# • wdqs: A SPARQL store loaded with Wikidata mappings optimized for WDQS.
# • pubchem-sparql: A SPARQL store loaded with PubChem RDF mappings.
kb = Store('mixer', [
Store('wdqs', 'https://query.wikidata.org/sparql'),
Store('pubchem-sparql', 'https://qlever.cs.uni-freiburg.de/api/pubchem')])
# Filter the subject and value (sv) of all statements where:
# • subject has chemical formula (P274) H₂O.
# • property is mass (P2067).
it = kb.filter_sv(subject=wd.chemical_formula('H₂O'), property=wd.mass)
for chem, mass in it:
print(chem, mass)
```
## 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. ["KIF: A Wikidata-Based Framework for Integrating Heterogeneous
Knowledge Sources"](https://arxiv.org/abs/2403.10304), arXiv:2403.10304,
2024.
## License
Released under the [Apache-2.0 license](./LICENSE).
Raw data
{
"_id": null,
"home_page": "https://github.com/IBM/kif",
"name": "kif-lib",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": "IBM",
"author_email": "Guilherme.Lima@ibm.com",
"download_url": "https://files.pythonhosted.org/packages/cb/f1/6ab2c6de2fa71a6e518eb4bd7f18bb3b7bebdffe3a187b8434a5a51a64cb/kif_lib-0.11.0.tar.gz",
"platform": null,
"description": "<img src=\"https://raw.githubusercontent.com/IBM/kif/refs/heads/main/docs/_static/kif-boxed.svg\" width=\"96\">\n\n# Knowledge Integration Framework\n\nKIF is a knowledge integration framework from [IBM\nResearch](https://research.ibm.com/).\n\nIt is based on [Wikidata](https://www.wikidata.org/) and licensed under the\n[Apache-2.0 license](./LICENSE).\n\nFirst time here? Check out the [quickstart\nguide](https://ibm.github.io/kif/quickstart.html).\n\n## Highlights\n\n* KIF is an interface to query knowledge sources as if they were Wikidata.\n\n* KIF queries are written as simple, high-level filters using entities of\n the [Wikidata data\n model](https://www.wikidata.org/wiki/Wikidata:Data_model).\n\n* KIF can be used to query Wikidata itself or other knowledge sources,\n provided proper mappings are given.\n\n* KIF comes with built-in mappings for [DBpedia](https://www.dbpedia.org/)\n and [PubChem RDF](https://pubchem.ncbi.nlm.nih.gov/docs/rdf). Other\n mappings can be added programmatically.\n\n* KIF has full support for\n [asyncio](https://docs.python.org/3/library/asyncio.html). KIF async API\n can be used run queries asynchronously, without blocking waiting on their\n results.\n\n## Installation\n\nLatest release:\n\n```shell\n$ pip install kif-lib\n```\n\nDevelopment version:\n\n```shell\n$ pip install kif-lib@git+https://github.com/IBM/kif.git\n```\n\n## Documentation\n\nSee [documentation](https://ibm.github.io/kif/) and [examples](./examples).\n\n### Hello world!\n\n<hr/>\n\n#### (1)\n\nGets from [Wikidata](https://www.wikidata.org/) all statements with property\n[shares border with (P47)](http://www.wikidata.org/entity/P47) and value\n[Brazil (Q155)](http://www.wikidata.org/entity/Q155).\n\nUsing the `kif` command-line utility:\n\n```shell\nkif filter -s wdqs --property=wd.shares_border_with --value='wd.Q(155)'\n```\n\n> (**Statement** (**Item** [Argentina](http://www.wikidata.org/entity/Q414)) (**ValueSnak** (**Property** [shares border with](http://www.wikidata.org/entity/P47)) (**Item** [Brazil](http://www.wikidata.org/entity/Q155)))) <br/>\n> (**Statement** (**Item** [Peru](http://www.wikidata.org/entity/Q419)) (**ValueSnak** (**Property** [shares border with](http://www.wikidata.org/entity/P47)) (**Item** [Brazil](http://www.wikidata.org/entity/Q155)))) <br/>\n> (**Statement** (**Item** [Paraguay](http://www.wikidata.org/entity/Q733)) (**ValueSnak** (**Property** [shares border with](http://www.wikidata.org/entity/P47)) (**Item** [Brazil](http://www.wikidata.org/entity/Q155)))) <br/>\n> \u22ee\n\nUsing the KIF API:\n\n```python\nfrom kif_lib import * # import the KIF namespace\nfrom kif_lib.vocabulary import wd # import the Wikidata vocabulary module\n\n# Create a SPARQL store loaded with Wikidata mappings and optimized for WDQS.\nkb = Store('wdqs', 'https://query.wikidata.org/sparql')\n\n# Filter all statements with the given property and value.\nfor stmt in kb.filter(property=wd.shares_border_with, value=wd.Q(155)):\n print(stmt)\n```\n\n<hr/>\n\n#### (2)\n\nGets from [Wikidata](https://www.wikidata.org/) and [PubChem\nRDF](https://qlever.cs.uni-freiburg.de/api/pubchem) the IRI and molecular\nmass of all chemicals whose formula is H\u2082O.\n\nUsing the `kif` command-line utility:\n\n```shell\n$ kif filter -s wdqs -s pubchem-sparql --select sv --subject='wd.chemical_formula(\"H\u2082O\")' --property=wd.mass\n```\n\n> (**Item** [hydrogen tritium oxide](http://www.wikidata.org/entity/Q106010186)) 20.01878893 [dalton](http://www.wikidata.org/entity/Q483261) <br/>\n> (**Item** [oxygen-15 atom](http://rdf.ncbi.nlm.nih.gov/pubchem/compound/CID10129877)) 17.0187 [dalton](http://www.wikidata.org/entity/Q483261) <br/>\n> (**Item** [diprotium oxide](http://www.wikidata.org/entity/Q106010185)) 18.010564684 [dalton](http://www.wikidata.org/entity/Q483261) <br/>\n> \u22ee\n\nUsing the KIF API:\n\n```python\n# Create a mixer store combining:\n# \u2022 wdqs: A SPARQL store loaded with Wikidata mappings optimized for WDQS.\n# \u2022 pubchem-sparql: A SPARQL store loaded with PubChem RDF mappings.\n\nkb = Store('mixer', [\n Store('wdqs', 'https://query.wikidata.org/sparql'),\n Store('pubchem-sparql', 'https://qlever.cs.uni-freiburg.de/api/pubchem')])\n\n# Filter the subject and value (sv) of all statements where:\n# \u2022 subject has chemical formula (P274) H\u2082O.\n# \u2022 property is mass (P2067).\n\nit = kb.filter_sv(subject=wd.chemical_formula('H\u2082O'), property=wd.mass)\nfor chem, mass in it:\n print(chem, mass)\n```\n\n## Citation\n\nGuilherme Lima, Jo\u00e3o M.\u00a0B.\u00a0Rodrigues, Marcelo Machado, Elton Soares, Sandro\nR.\u00a0Fiorini, Raphael Thiago, Leonardo G.\u00a0Azevedo, Viviane T.\u00a0da Silva, Renato\nCerqueira. [\"KIF: A Wikidata-Based Framework for Integrating Heterogeneous\nKnowledge Sources\"](https://arxiv.org/abs/2403.10304), arXiv:2403.10304,\n2024.\n\n## License\n\nReleased under the [Apache-2.0 license](./LICENSE).\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "A knowledge integration framework based on Wikidata",
"version": "0.11.0",
"project_urls": {
"Homepage": "https://github.com/IBM/kif"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "5dc456d9bfd8b99a3becfa38439511dee5de87c382773f5fd9b34a65ad61126d",
"md5": "58c8695644f1ed76b882ae42329348dd",
"sha256": "185391964d85f44e06e5fcde4dd66c36700c397e3fa3ed1c17a56981ff59ccab"
},
"downloads": -1,
"filename": "kif_lib-0.11.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "58c8695644f1ed76b882ae42329348dd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 467875,
"upload_time": "2025-07-15T20:10:34",
"upload_time_iso_8601": "2025-07-15T20:10:34.751517Z",
"url": "https://files.pythonhosted.org/packages/5d/c4/56d9bfd8b99a3becfa38439511dee5de87c382773f5fd9b34a65ad61126d/kif_lib-0.11.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "cbf16ab2c6de2fa71a6e518eb4bd7f18bb3b7bebdffe3a187b8434a5a51a64cb",
"md5": "5afc043b06afeba916846c4bb875d0d4",
"sha256": "3c17bf043d3db5feb37bd551837137f4cb9460fb76899e7a13e25abaed65aa74"
},
"downloads": -1,
"filename": "kif_lib-0.11.0.tar.gz",
"has_sig": false,
"md5_digest": "5afc043b06afeba916846c4bb875d0d4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 412221,
"upload_time": "2025-07-15T20:10:36",
"upload_time_iso_8601": "2025-07-15T20:10:36.232813Z",
"url": "https://files.pythonhosted.org/packages/cb/f1/6ab2c6de2fa71a6e518eb4bd7f18bb3b7bebdffe3a187b8434a5a51a64cb/kif_lib-0.11.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-15 20:10:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "IBM",
"github_project": "kif",
"travis_ci": false,
"coveralls": true,
"github_actions": false,
"tox": true,
"lcname": "kif-lib"
}