Skip to main content

Paradigm panes meant to provide layout specification to be reused elsewhere.

Project description

paradigm-panes

Installable package that produces a paradigm for a given word, given a pointer to paradigm layouts and FST file. Originally built for itwêwina.

PyPi Package

Latest version of the package posted to PyPi: paradigm-panes 0.3.2

Install

pip install paradigm-panes

Developing

Developing is done and managed through Python Poetry package manager.

To start development:

# Download the repo
git clone https://github.com/UAlbertaALTLab/paradigm-panes.git

# Set up virutal env
virtualenv venv --python=python3.9
source venv/bin/activate

# Install dependencies
poetry install

# Now cd into main directory and try out the package
cd paradigm_panes
python
    >>> import paradigm_panes
    >>> ...

API Documentation:

  • PaneGenerator()

    For successful execution, the package needs a link to resources as described below. To manage different links and use the panes generator more effectively, the package provides PaneGenerator class that allows managing settings and executing main functionality:

    >>> pane_generator = paradigm_panes.PaneGenerator()
    

    The class itself does not take any variables.

  • generate_pane()

    >>> paradigm = pane_generator.generate_pane(lemma, paradigm_type, size: Optional)
    

    This function is a core functionality of the package. Once the resources are specified, this function generates the pane according to the specification given.
    If the translations are not found in the FST file, some of the inflections will be indicated as missing. The resulted paradigm class is serialized and returned as JSON.

    Parameters:

    lemma(str) - base wordform to be inflected

    paradigm_type(str) - specification of the paradigm type of the word. Ex. "NA".

    size(str) - optional size of the pane to be returned. Currently supports "base", and "full". If the specified size is not found, overrides with default option.

  • all_analysis_template_tags()

    >>> paradigm = pane_generator.all_analysis_template_tags(paradigm_type)
    

    An additional functionality that returns all analysis template tags.

    Parameters:

    paradigm_type(str) - specification of the paradigm type of the word. Ex. "NA".

    tag_style(str) - style of tags to return.

    Specify tag style through settings

Usage and Configuration

Import the library:

>>> import paradigm_panes

Create PaneGenerator and specify path to FST file and layouts resources:

>>> pg = paradigm_panes.PaneGenerator()
>>> pg.set_layouts_dir("/home/ubuntu/paradigm_panes/resources/layouts")
>>> pg.set_fst_filepath("/home/ubuntu/paradigm_panes/resources/fst/crk-strict-generator.hfstol")

Pass lemma, paradigm type, and optional size to generate a pane:

>>> lemma = "amisk"
>>> p_type = "NA"
>>> paradigm = pg.generate_pane(lemma, p_type)

>>> p_size = "full"
>>> full_paradigm = pg.generate_pane(lemma, p_type, p_size)

Settings specification functions:

  • set_layouts_dir(path) specifies a location of a directory with paradigm layouts that are relevant for current paradigm generation.

  • set_fst_filepath(path) specifies FST file location with layout translation that are relevant for current paradigm generation.

  • set_tag_style(path) specifies template rendering type for all_analysis_template_tags function.

    Available tag styles:

    1. "Plus"
    2. "Bracket"

The generator must specify both locations (FST, layouts) before generating a paradigm.

Size is optional to paradigm generation; by default a base size (or first available) will be used.

Testing

To run the tests you need to install required dependencies, it is easier by using a virtual environment like this:

>>> # Set up virutal env
>>> virtualenv venv --python=python3.9
>>> source venv/bin/activate
>>>
>>> # Install dependencies
>>> poetry install

Once the dependencies are installed you can run tests by calling pytest.

>>> pytest

Release

Package version number is sorted in pyproject.toml. With every release to PyPi the version needs to be updated.
Build the package from the main directory before publishing it:

>>> poetry build

To publish to Test PyPi use poetry and enter credentials associated with Test PyPi account

>>> poetry publish -r testpypi

To publish to real PyPi use poetry and enter credentials associated with PyPi

>>> poetry publish

All relevant package specifications and dependencies are managed in pyproject.toml file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

paradigm-panes-0.3.5.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

paradigm_panes-0.3.5-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

Details for the file paradigm-panes-0.3.5.tar.gz.

File metadata

  • Download URL: paradigm-panes-0.3.5.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.0 Darwin/21.5.0

File hashes

Hashes for paradigm-panes-0.3.5.tar.gz
Algorithm Hash digest
SHA256 ca166e89664f810b982cf548271e89f4aa71397a339b1c5ed9bee3f3333470c6
MD5 f5296b6906fe10a36727aba0d8484a6a
BLAKE2b-256 8641984af552b3da335896fd8624448141746da355908c99113086a1cab4637c

See more details on using hashes here.

File details

Details for the file paradigm_panes-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: paradigm_panes-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 25.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.0 Darwin/21.5.0

File hashes

Hashes for paradigm_panes-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 647af90b2ccedc63356a7f35d4cde653dad2a7fd7d217df81c1b82901cc44396
MD5 a826e3a152d44ac16a65ffd1dff13150
BLAKE2b-256 ac01f005acab91c800adca069eb769c3224b34edb5a8049f23b27f7dd658ce22

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page