Library for semantic annotation of tabular data with the Wikidata knowledge graph
Project description
bbw (boosted by wiki)
- Annotates tabular data with the entities, types and properties in Wikidata.
- Easy to use: bbw.annotate().
- Resolves even tricky spelling mistakes via meta-lookup through SearX.
- Matches to the up-to-date values in Wikidata without the dump files.
- Ranked in third place at SemTab2020.
Table of contents
How to use
Import library
from bbw import bbw
The easiest way to annotate the dataframe Y is:
[web_table, url_table, label_table, cpa, cea, cta] = bbw.annotate(Y)
It returns a list of six dataframes. The first three dataframes contain the annotations in the form of HTML-links, URLs and labels of the entities in Wikidata correspondingly. The dataframes have two more rows than Y. These two rows contain the annotations for types and properties. The last three dataframes contain the annotations in the format required by SemTab2020 challenge.
The fastest way to annotate the dataframe Y is:
[cpa_list, cea_list, nomatch] = bbw.contextual_matching(bbw.preprocessing(Y))
[cpa, cea, cta] = bbw.postprocessing(cpa_list, cea_list)
The dataframes cpa
, cea
and cta
contain the annotations in SemTab2020-format. The list nomatch
contains the labels which are not matched. The unprocessed and possibly non-unique annotations are in the lists cpa_list
and cea_list
.
GUI
If you need to annotate only one table, use the simple GUI:
streamlit run bbw_gui.py
Open the browser at http://localhost:8501 and choose a CSV-file. The annotation process starts automatically. It outputs the six tables of the annotate function.
Try it out online (no SearX support) with this binder link.
CLI
If you need to annotate a few tables, use the CLI-tool:
python3 bbw_cli.py --amount 100 --offset 0
GNU parallel
If you need to annotate hundreds or thousands of tables, use the script with GNU parallel:
./bbw_parallel.py
Installation
You can use pip to install bbw:
pip install bbw
The latest version can be installed directly from github:
pip install git+https://github.com/UB-Mannheim/bbw
You can test bbw in a virtual environment:
pip install virtualenv
virtualenv testing_bbw
source testing_bbw/bin/activate
python
from bbw import bbw
[web_table, url_table, label_table, cpa, cea, cta] = bbw.annotate(bbw.pd.DataFrame([['0','1'],['Mannheim','Rhine']]))
print(web_table)
deactivate
Install also SearX, because bbw meta-lookups through it.
export PORT=80
docker pull searx/searx
docker run --rm -d -v ${PWD}/searx:/etc/searx -p $PORT:8080 -e BASE_URL=http://localhost:$PORT/ searx/searx
SearX is running on http://localhost:80. bbw sends GET requests to it.
Citing
If you find bbw useful in your work, a proper reference would be:
@inproceedings{2020_bbw,
author = {Renat Shigapov and Philipp Zumstein and Jan Kamlah and Lars Oberl{\"a}nder and J{\"o}rg Mechnich and Irene Schumm},
title = {bbw: {M}atching {CSV} to {W}ikidata via {M}eta-lookup},
booktitle = {SemTab@ISWC 2020},
year = {2020}
}
[preprint] [presentation] [BERD@BW]
SemTab2020
The library was designed, implemented and tested during SemTab2020. It received the best scores in the last 4th round at automatically generated dataset:
Task | F1-score | Precision | Rank |
---|---|---|---|
CPA | 0.995 | 0.996 | 2 |
CTA | 0.980 | 0.980 | 2 |
CEA | 0.978 | 0.984 | 4 |
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
File details
Details for the file bbw-0.1.2.tar.gz
.
File metadata
- Download URL: bbw-0.1.2.tar.gz
- Upload date:
- Size: 27.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 446033d87be6f4e9ca763135dc89a1fef03dfb75199a3276ec3009ad0c97c92f |
|
MD5 | 1f124511aba094e240009917ee512e47 |
|
BLAKE2b-256 | 7d599738a38fa5d7b14ecb2d50e02a74991635e4ccb6a9267345e51a456a8137 |
File details
Details for the file bbw-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: bbw-0.1.2-py3-none-any.whl
- Upload date:
- Size: 19.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e6fad119702e8c9b92610b731744d22f67c619a7d9272c0cb08995ca2081b9c |
|
MD5 | 3052dd543207c599f02f4ba63fdd9177 |
|
BLAKE2b-256 | 685e6346e25593401d158cde920e0ae8009f7e5db861df529422a2dcbc4ec4e6 |