Giter Site home page Giter Site logo

wd2tantivy's Introduction

wd2tantivy

A program for generating a tantivy index from a Wikidata dump.

License

Usage

Clone the repository and run the following command to install the package inside of a virtual environment:

poetry install

wd2tantivy requires only the compressed (.gz) Wikidata truthy dump in the N-Triples format as input. You can download it with the following command:

wget https://dumps.wikimedia.org/wikidatawiki/entities/latest-truthy.nt.gz

wd2tantivy uses spaCy to lemmatize the aliases. This means you need to download the appropriate model you wish to use first.

For example:

poetry run python -m spacy download en_core_web_lg

After downloading the dump and the model, you can generate the tantivy index with the following command:

pigz -dc latest-truthy.nt.gz | \
poetry run wd2tantivy --language "${LANGUAGE}" \
                      --spacy-model "${SPACY_MODEL}" \
                      --output "${OUTPUT_DIR}"

Where ${LANGUAGE} is a BCP-47 language code.

The tantivy index will be written into ${OUTPUT_DIR}.

Each document in the index contains 3 stored and indexed fields:

  • qid (integer)
  • preferred name (NFC normalized, UTF-8 encoded text)
  • alias (lemmatized, NFC normalized, UTF-8 encoded text); this field can have multiple values

Performance

wd2tantivy uses as many threads as there are logical CPU cores. On a dump from March 2023, containing ~100,000,000 nodes, it takes ~5 hours to complete for English with peak memory usage of ~70GB on an AMD Ryzen Threadripper 3970X CPU and an SSD.

wd2tantivy's People

Contributors

cyanic-selkie avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.