sigmorphon-vp
sigmorphon-vp is a typed utility package for downloading, converting, merging, and pre-encoding SigMorphon-style morphological reinflection datasets.
PyPI package name:
pip install sigmorphon-vp
Import name:
import sigmorphon
The package is designed to work well with chartoken-vp, but it stays publishable as its own package.
What it provides
sigmorphon-vp covers the data layer around morphological reinflection:
- download helpers for SigMorphon 2021 Task 0 style data
- conversion from upstream raw files into a consistent internal TSV format
- merge helpers for multi-language training corpora
- typed TSV loading
- an in-memory
MorphDatasetthat pre-encodes examples into tensors
Internal TSV format
The package converts data into a normalized 4-column TSV format:
lemma<TAB>features<TAB>surface<TAB>lang
Example:
walk V;PST walked eng
Comment lines beginning with # are allowed and ignored by the loaders.
Installation
Requirements:
- Python
>=3.14 - PyTorch
>=2.0 chartoken-vp>=2.1.0
Install from PyPI:
pip install sigmorphon-vp
Downloading datasets
The downloader exposes:
DATASETSdownload_languagedownload_allget_available_languagesmerge_tsv
Quick example:
from pathlib import Path
from sigmorphon import download_all, merge_tsv
out_dir = Path("data")
download_all(["rus", "bul", "spa"], out_dir)
train_files = sorted(out_dir.glob("*_train.tsv"))
merge_tsv(train_files, out_dir / "merged_train.tsv")
What download does
For each requested language, the package:
- downloads upstream raw files
- stores them under
raw/ - converts them to the internal TSV layout
- deduplicates rows with an MD5 hash
- writes
*_train.tsvand*_dev.tsv
If converted files already exist, the downloader skips them.
Discovering languages
get_available_languages() tries to read the list of languages from the SigMorphon GitHub repository. If that request fails, it falls back to the built-in DATASETS mapping.
Loading data
Simple TSV loading:
from sigmorphon import load_tsv
rows = load_tsv("data/rus_train.tsv")
Glob pattern loading:
from sigmorphon import load_tsv_pattern
rows = load_tsv_pattern("data/*_train.tsv")
Returned row type:
MorphRow = tuple[str, list[str], str, str]
That is:
- lemma
- feature list
- surface form
- language code
MorphDataset
MorphDataset is the package's main runtime component. It converts rows into ready-to-train tensors using:
CharVocabFeatureVocab- a
lang_to_idmapping
Constructor inputs:
rowschar_vocabfeature_vocablang_to_idmax_lenmax_featurespin_memory
Produced tensors:
- source character ids
- target character ids
- feature ids
- feature masks
- language ids
Batch serving
MorphDataset.epoch_batches(...) yields batches in the following typed layout:
MorphBatch = tuple[
torch.Tensor, # source
torch.Tensor, # target
torch.Tensor, # language ids
torch.Tensor, # feature ids
torch.Tensor, # feature mask
]
Behavior:
- shuffles sample order each epoch
- supports CUDA-aware non-blocking transfers
- uses a secondary CUDA stream for prefetch when available
- keeps all pre-encoded samples in RAM for fast iteration
Example:
import torch
from chartoken import CharVocab, FeatureVocab
from sigmorphon import MorphDataset, load_tsv
rows = load_tsv("data/rus_train.tsv")
char_vocab = CharVocab.from_texts([lemma for lemma, _, _, _ in rows] + [surface for _, _, surface, _ in rows])
feature_vocab = FeatureVocab.from_tags([tags for _, tags, _, _ in rows])
lang_to_id = {"rus": 0}
dataset = MorphDataset(rows, char_vocab, feature_vocab, lang_to_id)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
for source, target, lang_ids, feature_ids, feature_mask in dataset.epoch_batches(32, device):
print(source.shape, target.shape)
break
Utility methods
MorphDataset.memory_bytes() estimates how much RAM the encoded tensors occupy.
That is useful when you want to:
- compare eager dataset sizes across languages
- plan batch sizes
- decide whether to split or merge corpora
Intended scope
This package intentionally focuses on morphological dataset handling. It does not contain:
- neural network layers
- training loops
- checkpointing
- model definitions
That separation keeps the package reusable across multiple applications, not just morphoformer.
Metadata
Release files for sigmorphon-vp 3.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sigmorphon_vp-3.0.0.tar.gz | 9.1 kB | Without provenance | Details for sigmorphon_vp-3.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sigmorphon_vp-3.0.0-py3-none-any.whl | Python 3 | none | any | Details for sigmorphon_vp-3.0.0-py3-none-any.whl |
Total release size: 16.9 kB
Release files / sigmorphon_vp-3.0.0.tar.gz
| Download URL | sigmorphon_vp-3.0.0.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ca59fb4bad53115b82184b0bdb23272fcb31ecbe1115cca58d940cdd8b40cf2b
|
|
BLAKE2b-256 checksum How to use checksums |
30980a1f867e44d6f0a7834be3ad92bf57befeb6b8b7aef4387c4f38028c6441
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / sigmorphon_vp-3.0.0-py3-none-any.whl
| Download URL | sigmorphon_vp-3.0.0-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2541808030ebecfd745ed985b2088b133e48243249c5f31164aeb74614268847
|
|
BLAKE2b-256 checksum How to use checksums |
318f39c692e5e2a18d78c5b06cdb84e77fb81e026826cf6de8e71467119eacf7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Security for sigmorphon-vp 3.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.