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
formfield; - create a new field called
starwhich will contain the value of theformfield 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.
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-rootpoetry buildpoetry 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;
emdummyPython 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 module as a new repo based on this template repo, name it
emNAME.
Change alldummy/Dummyoccurrences toNAMEwith appropriate letter casing in all files insrc/emdummy,Makefileandpyproject.toml.
Set also author etc. in the latter.
In mind, replacedummywithNAMEeverywhere 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.pyfor further information. - Write a brand new
README.md.
After the Python package is ready:
make testruns emdummy on tests/input/*.tsv
and compares the output with tests/gold/*.tsv.
See information in docs/CONTRIBUTING.md
- Check
pyproject.toml. Before your very first release, setversion = "0.0.0". make release-majorormake release-minorormake 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
gitTAG - Release the package on github
- Upload a new pypi package
- Install
emtsv: 1st and 2nd point +cythononly. - Go to the
emtsvdirectory (cd emtsv). - Add
emdummyby adding this line torequirements.txt:
https://github.com/THISUSER/emdummy/releases/download/vTAG/emdummy-TAG-py3-none-any.whl - Complete
config.pyby addingem_dummyandtoolsfromemdummy/__main__.pyappropriately. - Complete
emtsvinstallation bymake venv. echo "A kutya ment volna el sétálni." | venv/bin/python3 ./main.py tok,morph,pos > oldecho "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! :)