Awesome
emdummy
A template module for xtsv
Take a look at this toy module for getting started
writing an xtsv
module.
This module is for educational purposes. It solves an extremely simple task:
- takes the value of the
form
field; - create a new field called
star
which will contain the value of theform
field together with an added asterisk on both sides.
E.g. if the form
field is kutya
the star
field will be *kutya*
.
It is demonstrated that the order of the columns does not affect the operation of xtsv
.
Content howto
Python package creation
Poetry and (optionally) GNU Make are required.
git clone https://github.com/REPO_NAME.git
- Run
make
On Windows or without Make (after cloning the repository):
poetry install --no-root
poetry build
poetry run pip install --upgrade dist/*.whl
(the correct filename must be specified on Windows)
(optional) To install extras run: poetry install -E [NAME OF THE EXTRA TO INSTALL]
By executing make
you run all the following:
- a virtual environment is created;
emdummy
Python package is created indist/emdummy-*-py3-none-any.whl
;- the package is installed in the virtualenv;
- the package is tested (see testing).
The above steps can be performed separately by make venv
, make build
, make install
and make test
respectively.
The Python package can be installed anywhere by direct path:
pip install path/to/emdummy-*-py3-none-any.whl
Create your own module
- Create your module as a new repo based on this template repo, name it
emNAME
.
Change alldummy/Dummy
occurrences toNAME
with appropriate letter casing in all files insrc/emdummy
,Makefile
andpyproject.toml
.
Set also author etc. in the latter.
In mind, replacedummy
withNAME
everywhere in the rest of this document. - Set
source_fields
(names of fields your module uses as input) andtarget_fields
(names of fields your module adds) insrc/emdummy/__main__.py
. - See comments in
src/emdummy/emdummy.py
for further information. - Write a brand new
README.md
.
Testing
After the Python package is ready:
make test
runs emdummy
on tests/input/*.tsv
and compares the output with tests/gold/*.tsv
.
Setting up CI/CD environment
See information in docs/CONTRIBUTING.md
- Check
pyproject.toml
. Before your very first release, setversion = "0.0.0"
. make release-major
ormake release-minor
ormake release-patch
. If in doubt, read about semantic versoning. This will (if [CI/CD has been set up correctly](#setting up CI-CD-environment))- Update the version number appropriately
- Make a
git commit
- Make a
git
TAG - Release the package on github
- Upload a new pypi package
Add the released package to emtsv
- Install
emtsv
: 1st and 2nd point +cython
only. - Go to the
emtsv
directory (cd emtsv
). - Add
emdummy
by adding this line torequirements.txt
:
https://github.com/THISUSER/emdummy/releases/download/vTAG/emdummy-TAG-py3-none-any.whl
- Complete
config.py
by addingem_dummy
andtools
fromemdummy/__main__.py
appropriately. - Complete
emtsv
installation bymake venv
. echo "A kutya ment volna el sétálni." | venv/bin/python3 ./main.py tok,morph,pos > old
echo "A kutya ment volna el sétálni." | venv/bin/python3 ./main.py tok,morph,pos,dummy > new
- See results e.g. by
diff old new
. - If everything is in order, create a PR for
emtsv
.
That's it! :)