Skip to main content

Morpheme Segmentation in Multi- and Monolingual Wordlists

This package provides implementations for several algorithms by which words in a wordlist can be segmented into morphemes.

If you use this software package, please cite it accordingly:

Rubehn, A. and J.-M. List (2025). MorSeg: A Python package for morpheme segmentation in multi- and monolingual wordlists [Software Library, Version 0.1]. Chair for Multilingual Computational Linguistics, University of Passau.

Installation

This package can be conveniently installed using pip:

pip install morseg

Basic Usage

Loading data

Assuming your data is presented in a TSV file following the LingPy specifications (see /tests/test_data/german.tsv for an example), you can simply load your data with:

from morseg.utils.wrappers import WordlistWrapper

wl = WordlistWrapper.from_file(YOUR_FILE)

This creates a wordlist wrapper object; a representation of a wordlist with three annotation levels: The predicted segmentations (by a model), the Gold standard segmentations, and the unsegmented form. The training of all models requires the data to be stored in this class!

Training a model

The Tokenizer class offers a unified interface for all models that are implemented in this library. For example, if you want to train a LSV (Letter Successor Variety) model, you can simply do so like that:

from morseg.algorithms.tokenizer import LSVTokenizer

model = LSVTokenizer()
model.train(wl)

The current release covers implementations of the following models:

Furthermore, some popular models for subword tokenization are implemented:

Obtain segmentations

You can obtain the predicted segmentations from your training data by calling:

for segmented_word in model.get_segmentations():
    # do whatever

You can also try segmenting unseen words (depending on the model, this might work more or less well):

word = ["w", "o", "r", "d"]
segmented_word = model(word)

Release files for morseg 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for morseg 0.1
File Size Uploaded
morseg-0.1.tar.gz 17.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for morseg 0.1
File Interpreter ABI Platform
morseg-0.1-py3-none-any.whl Python 3 none any Details

Total release size: 34.3 kB

Release files / morseg-0.1.tar.gz

Download URL morseg-0.1.tar.gz
Size 17.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d2dd394190085c0e384a83d0771c519d31c231e966bfe7ea225e624d74435e1e
BLAKE2b-256 checksum
How to use checksums
cf518f9567651b27bfe0c6caaf7c341a2c980cbfff1b4defb39b4e41e8e39b36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.0

Release files / morseg-0.1-py3-none-any.whl

Download URL morseg-0.1-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca60f0dcddc56cb156918ab14fde7a81b91177a77507f3f7cfafd7fc937b234c
BLAKE2b-256 checksum
How to use checksums
db041ace253a2b29cbf01b233bbbe6a6b0eb457bffb860b360823a3dcba509a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.0

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page