User guide
Installation
Requirements
Python 3.10 or later: If possible, use the latest release of Python, which can be downloaded from the official website. This guide assumes you are familiar with the basics of Python.
pip: Python's built-in package manager. It is usually included in the default Python installation. If you don't have it, the documentation has installation instructions.
Currently, tparser does not have any dependencies that need to be separately installed.
Using virtual environments
This is not required, but it is recommended. Virtual environments allow you to install and manage packages for specific projects.
Python has a built-in library venv that you can use. If you choose to install tparser in a virtual environment, please make sure it is created and activated before continuing!
Install using pip
The easiest way is to install tparser is from the latest release in Releases.
Under Assets, copy the link to the wheel file (ending in .whl). This should work for most systems and environments. In case it doesn't work, try the link to the source distribution file (ending in .tar.gz).
The link for version X.Y.Z should look something like
https://github.com/06j07m/tparser/releases/download/vX.Y.Z/tparser-X.Y.Z-py3-none-any.whl
Navigate to your project folder.
Replace LINK in the command below with the link you just copied and run it:
pip install LINK
Alternatively, you can download the .whl or .tar.gz file and install tparser from the downloaded file. Just replace LINK in the command above with the path to the file.
Finally, you can also install tparser from the repository using
pip install git+https://github.com/06j07m/tparser
Build from source code
If you want to build tparser from source, you'll need to install the build and setuptools packages.
Download the source code from the latest release in Releases and unzip it.
Navigate to the root folder, which contains a pyproject.toml file.
Run the command below (your installation of Python might be accessed using a different command, such as python3 or py):
python -m build
This will create a folder named dist, inside of which you will find the wheel and source distribution builds. You can then install these using pip as shown above.
conda or other package managers
tparser currently does not support installation directly using conda. However, you can use pip inside your conda environement to install it.
Similarly, other Python package managers that use wheel files, such as uv, should work but are not guaranteed to.
Detailed usage
Import the Parser class
tparser has one main class called Parser, which contains all the functionality needed to parse a verb.
>>> from tparser import Parser
Create a Parser instance
In order to use the class, you need to create an instance of it.
>>> parser = Parser()
Currently, the constructor does not take any arguments and it uses data stored within the package.
Future versions may allow you to create a parser using a custom list of suffixes.
Parse a verb
The Parser class has one public method called parse_word. To parse a verb, simply pass it as a string to the method.
>>> parser.parse_word("dusáagun")
verb: dusáagun
options: du|sáag|un, dusáa|gu|n, dusáa|gu|n, dusáa|gun
verb root options: sak, gut, gu, gun
[('du', 'sak', 'un'), ('dusáa', 'gut', 'n'), ('dusáa', 'gu', 'n'), ('dusáa', 'gun', '')]
This will return a list of possible parsings. Each parsing is represented as a tuple with 3 elements: the prefix(es), the root, and the suffix(es).
In this example, the first possible parsing is that du- is the prefix, sak is the root, and -un is the suffix.
Please note that there may be incorrect parsings found, and that the correct parsing is not guaranteed to be found.
[ ('du', 'sak', 'un'),
('dusáa', 'gut', 'n'),
('dusáa', 'gu', 'n'),
('dusáa', 'gun', '') ]
It will also print, by default, a visual representation of the possible parsings. This shows:
- the verb in its normalized form (i.e. in lowercase with standardized characters and diacritics)
- each parsing with a pipe symbol separating the prefix(es), stem, and suffix(es)
- the root derived from each parsing
In this example, the first possible parsing in the list has the stem sáag, corresponding to the root sak.
verb: dusáagun
options: du|sáag|un, dusáa|gu|n, dusáa|gu|n, dusáa|gun
verb root options: sak, gut, gu, gun
Suppress display
parse_word has an optional argument called no_display, which defaults to False. Set it to True if you don't want the visual respresentations to be printed.
>>> parser.parse_word("dusáagun", no_display=True)
[('du', 'sak', 'un'), ('dusáa', 'gut', 'n'), ('dusáa', 'gu', 'n'), ('dusáa', 'gun', '')]