wordseg
wordseg is a Python package of word segmentation models.
Table of contents:
Installation
wordseg is available through pip:
pip install wordseg
To install wordseg from the GitHub source:
git clone https://github.com/jacksonllee/wordseg.git
cd wordseg
pip install -e ".[dev]"
Usage
wordseg implements a word segmentation model as a Python class.
An instantiated model class object has the following methods
(emulating the scikit-learn-styled API for machine learning):
fit: Train the model with segmented sentences.predict: Predict the segmented sentences from unsegmented sentences.
The implemented model classes are as follows:
RandomSegmenter: Segmentation is predicted at random at each potential word boundary independently for some given probability. No training is required.LongestStringMatching: This model constructs predicted words by moving from left to right along an unsegmented sentence and finding the longest matching words, constrained by a maximum word length parameter.
Sample code snippet:
from src.wordseg import LongestStringMatching
# Initialize a model.
model = LongestStringMatching(max_word_length=4)
# Train the model.
# `fit` takes an iterable of segmented sentences (a tuple or list of strings).
model.fit(
[
("this", "is", "a", "sentence"),
("that", "is", "not", "a", "sentence"),
]
)
# Make some predictions; `predict` gives a generator, which is materialized by list() here.
list(model.predict(["thatisadog", "thisisnotacat"]))
# [['that', 'is', 'a', 'd', 'o', 'g'], ['this', 'is', 'not', 'a', 'c', 'a', 't']]
# We can't get 'dog' and 'cat' because they aren't in the training data.
License
MIT License. Please see LICENSE.txt.
Changelog
Please see CHANGELOG.md.
Contributing
Please see CONTRIBUTING.md.
Citation
Lee, Jackson L. 2023. wordseg: Word segmentation models in Python. https://doi.org/10.5281/zenodo.4077433
@software{leengrams,
author = {Jackson L. Lee},
title = {wordseg: Word segmentation models in Python},
year = 2023,
doi = {10.5281/zenodo.4077433},
url = {https://doi.org/10.5281/zenodo.4077433}
}
Metadata
Release files for wordseg 0.0.5
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 |
|---|---|---|---|---|
| wordseg-0.0.5.tar.gz | 6.2 kB | Without provenance | Details for wordseg-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wordseg-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for wordseg-0.0.5-py3-none-any.whl |
Total release size: 12.4 kB
Release files / wordseg-0.0.5.tar.gz
| Download URL | wordseg-0.0.5.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0ba2b87bcfa801508e8dbeb71c62d3056fc462b2610fd5d883680f636204700c
|
|
BLAKE2b-256 checksum How to use checksums |
52f8fdf2a02790257d75017a36018ea7ce7f8530beaecec6dc97ba7c46769dc5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.5
|
Release files / wordseg-0.0.5-py3-none-any.whl
| Download URL | wordseg-0.0.5-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7c607f58e040c19d187e2886b093b06470ba016454377e19f63e1b866774b3d6
|
|
BLAKE2b-256 checksum How to use checksums |
5ef436a9e82678df2f11fdb5803c7463854b63b4151fff729aba807e4d7f665c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.5
|
Security for wordseg 0.0.5
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.