text-selection
Command-line interface (CLI) to select lines of a text file.
Features
- dataset
create: create a dataset based on a text fileexport-statistics: exporting statistics to a CSV
- subsets
add: add subsetsremove: remove subsetsrename: rename subsetselect-all: select all linesselect-fifo: select lines FIFO-styleselect-greedily: select lines greedily regarding unitsselect-greedily-ep: select lines greedily regarding units (epoch-based)select-uniformly: select lines with units uniformly distributedselect-randomly: select lines randomlyfilter-duplicates: filter duplicate linesfilter-by-regex: filter lines by regexfilter-by-text: filter lines by textfilter-by-weight: filter lines by weightfilter-by-vocabulary: filter lines by unit vocabularyfilter-by-count: filter lines by global unit frequenciesfilter-by-unit-freq: filter lines by unit frequencies per linefilter-by-line-nr: filter lines by line numbersort-by-line-nr: sort lines by line numbersort-by-text: sort lines by textsort-by-weight: sort lines by weightssort-by-shuffle: shuffle linesreverse: reverse linesexport: export lines
- weights
create-from-file: create weights from filecreate-uniform: create uniform weightscreate-from-count: create weights from unit countdivide: divide weights
Roadmap
- add tests
- refactoring
- outsourcing greedy- and KLD-iterator
Installation
pip install text-selection --user
Usage
usage: text-selection-cli [-h] [-v] {dataset,subsets,weights} ...
CLI to select lines of a text file.
positional arguments:
{dataset,subsets,weights} description
dataset dataset commands
subsets subsets commands
weights weights commands
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
Dependencies
tqdmnumpyscipypandasordered_set>=4.1.0
Contributing
If you notice an error, please don't hesitate to open an issue.
Development setup
# update
sudo apt update
# install Python 3.8, 3.9, 3.10 & 3.11 for ensuring that tests can be run
sudo apt install python3-pip \
python3.8 python3.8-dev python3.8-distutils python3.8-venv \
python3.9 python3.9-dev python3.9-distutils python3.9-venv \
python3.10 python3.10-dev python3.10-distutils python3.10-venv \
python3.11 python3.11-dev python3.11-distutils python3.11-venv
# install pipenv for creation of virtual environments
python3.8 -m pip install pipenv --user
# check out repo
git clone https://github.com/stefantaubert/text-selection.git
cd text-selection
# create virtual environment
python3.8 -m pipenv install --dev
Running the tests
# first install the tool like in "Development setup"
# then, navigate into the directory of the repo (if not already done)
cd text-selection
# activate environment
python3.8 -m pipenv shell
# run tests
tox
Final lines of test result output:
py38: commands succeeded
py39: commands succeeded
py310: commands succeeded
py311: commands succeeded
congratulations :)
License
MIT License
Acknowledgments
Funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) – Project-ID 416228727 – CRC 1410
Citation
If you want to cite this repo, you can use this BibTeX-entry generated by GitHub (see About => Cite this repository).
Changelog
- v0.0.3 (2023-05-30)
- Changed
- Improved speed for filtering OOV/IV words by up to ~20k words/s
- Added
- Added
subsets select-randomly - Added
subsets sort-by-shuffle - Added
subsets addoption--skip-existing
- Added
- Bugfix
- Fixed evaluation of "from subsets" to ensure that the subsets exist
- Fixed
subsets removedidn't worked
- Changed
- v0.0.2 (2023-01-13)
- Added
- Added creation of weights from lines
- Add
--limitto select duplicates - Add exit code
- Changed
- Set
--limitpositional where applicable - Don't output expected warning from
numpyon KLD selection
- Set
- Bugfixes
- Added
- v0.0.1 (2022-05-25)
- Initial release
Release files for text-selection 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| text-selection-0.0.3.tar.gz | 112.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| text_selection-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 264.7 kB
Release files / text-selection-0.0.3.tar.gz
| Download URL | text-selection-0.0.3.tar.gz |
|---|---|
| Size | 112.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7bce559179c8a1254059e29c32526da4435685ac8ff6ded63434ddd63ac4d6c9
|
|
BLAKE2b-256 checksum How to use checksums |
0332434bd8f13bfb547fe1b75b0047949ec3377715221290f395fd901815d370
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / text_selection-0.0.3-py3-none-any.whl
| Download URL | text_selection-0.0.3-py3-none-any.whl |
|---|---|
| Size | 152.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ad75d5f83557f7e635dbcaae247ebf8f41067ea436cc5a2a04095f083adab3ff
|
|
BLAKE2b-256 checksum How to use checksums |
bc36fb7b12e17fe9ea7638697d06291abf2f2ada109f9b68d24e2469b0ba2c60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|