Expanda
The universal integrated corpus-building environment.
Introduction
Expanda is an integrated corpus-building environment. Expanda provides integrated pipelines for building a corpus dataset. Building corpus dataset requires several complicated pipelines such as parsing, shuffling, and tokenization. If the corpora are gathered from different applications, it would be a problem to parse various formats. Expanda helps to build corpus simply at once by setting build configuration.
For more information, see also documentation.
Main Features
- Easy to build, simple for adding new extensions
- Manages build environment systemically
- Fast build through performance optimization (even written in Python)
- Supports multi-processing
- Extremely less memory usage
- Don't need to write new codes for each corpus. Just write one line for adding a new corpus.
Dependencies
- nltk
- ijson
- tqdm>=4.46.0
- mwparserfromhell>=0.5.4
- tokenizers>=0.7.0
- kss==1.3.1
Installation
With pip
Expanda can be installed using pip as follows:
$ pip install expanda
From source
You can install from source by cloning the repository and running:
$ git clone https://github.com/affjljoo3581/Expanda.git
$ cd Expanda
$ python setup.py install
Build your first dataset
Let's build Wikipedia dataset by using Expanda. First of all, install Expanda.
$ pip install expanda
Next, create a workspace to build dataset by running:
$ mkdir workspace
$ cd workspace
Then, download Wikipedia dump file from here.
In this example, we are going to test with part of the wiki.
Download the file through the browser, move to workspace/src and rename to
wiki.xml.bz2. Instead, run below code:
$ mkdir src
$ wget -O src/wiki.xml.bz2 https://dumps.wikimedia.org/enwiki/20200520/enwiki-20200520-pages-articles1.xml-p1p30303.bz2
After downloading the dump file, we need to setup the configuration file.
Create expanda.cfg file and write the below:
[expanda.ext.wikipedia]
num-cores = 6
[tokenization]
unk-token = <unk>
control-tokens = <s>
</s>
<pad>
[build]
input-files =
--expanda.ext.wikipedia src/wiki.xml.bz2
The current directory structure of workspace should be as follows:
workspace
├── src
│ └── wiki.xml.bz2
└── expanda.cfg
Now we are ready to build! Run Expanda by using:
$ expanda build
Then we can get the below output:
[*] execute extension [expanda.ext.wikipedia] for [src/wiki.xml.bz2]
[nltk_data] Downloading package punkt to /home/user/nltk_data...
[nltk_data] Unzipping tokenizers/punkt.zip.
[*] merge extracted texts.
[*] start shuffling merged corpus...
[*] optimum stride: 17, buckets: 34
[*] create temporary bucket files.
[*] successfully shuffle offsets. total offsets: 102936
[*] shuffle input file: 100%|████████████████████| 102936/102936 [00:02<00:00, 34652.03it/s]
[*] start copying buckets to the output file.
[*] finish copying buckets. remove the buckets...
[*] complete preparing corpus. start training tokenizer...
[00:00:59] Reading files ████████████████████ 100
[00:00:04] Tokenize words ████████████████████ 405802 / 405802
[00:00:00] Count pairs ████████████████████ 405802 / 405802
[00:00:01] Compute merges ████████████████████ 6332 / 6332
[*] create tokenized corpus.
[*] tokenize corpus: 100%|█████████████████████| 1749902/1749902 [00:28<00:00, 61958.55it/s]
[*] split the corpus into train and test dataset.
[*] remove temporary directory.
[*] finish building corpus.
If you build dataset successfully, you can get the following directory tree:
workspace
├── build
│ ├── corpus.raw.txt
│ ├── corpus.train.txt
│ ├── corpus.test.txt
│ └── vocab.txt
├── src
│ └── wiki.xml.bz2
└── expanda.cfg
Metadata
Release files for Expanda 1.3.1
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 |
|---|---|---|---|---|
| Expanda-1.3.1.tar.gz | 13.3 kB | Without provenance | Details for Expanda-1.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| Expanda-1.3.1-py3-none-any.whl | Python 3 | none | any | Details for Expanda-1.3.1-py3-none-any.whl |
Total release size: 34.5 kB
Release files / Expanda-1.3.1.tar.gz
| Download URL | Expanda-1.3.1.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a0f0a83f997c3243b90318822997d3fbbead272a7765e239cab437f15c88a8f7
|
|
BLAKE2b-256 checksum How to use checksums |
d13f37d91da7db21350d7e4885070c746819f0c6500d52bbcdf64d31a5d86eda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7
|
Release files / Expanda-1.3.1-py3-none-any.whl
| Download URL | Expanda-1.3.1-py3-none-any.whl |
|---|---|
| Size | 21.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
89017e481b3079b520c3f129e9c7ec0bfcbc15ce5743c11f826f7f1829117629
|
|
BLAKE2b-256 checksum How to use checksums |
a0c1e39eaceebeb3dd8639b5bc9d08af318e2674b3fd2ebfab430c875d0a9206
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7
|
Security for Expanda 1.3.1
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.