Grapheme Cluster Break (Python)
A high-performance Python library for segmenting Unicode strings into grapheme clusters (user-perceived characters) according to UAX #29: Unicode Text Segmentation.
Installation
pip install grapheme-cluster-break
Usage
from grapheme_cluster_break import segment_grapheme_clusters
# Basic usage
clusters = segment_grapheme_clusters("Hello")
print(clusters) # ['H', 'e', 'l', 'l', 'o']
# Emoji ZWJ sequences
clusters = segment_grapheme_clusters("👨👩👧👦")
print(clusters) # ['👨👩👧👦']
# Combining characters
clusters = segment_grapheme_clusters("é") # e + combining acute accent
print(clusters) # ['é']
# Regional indicators (flags)
clusters = segment_grapheme_clusters("🇨🇳🇺🇸")
print(clusters) # ['🇨🇳', '🇺🇸']
# Indic conjuncts
clusters = segment_grapheme_clusters("क्ष") # Devanagari ksha
print(clusters) # ['क्ष']
# CJK characters
clusters = segment_grapheme_clusters("你好世界")
print(clusters) # ['你', '好', '世', '界']
# Hangul
clusters = segment_grapheme_clusters("한글")
print(clusters) # ['한', '글']
API Reference
segment_grapheme_clusters(s, extended=True)
Segments a UTF-8 string into grapheme clusters.
Parameters:
s(str) - The input string to segment.extended(bool, optional) - IfTrue(default), uses extended grapheme cluster rules. IfFalse, uses legacy rules.
Returns:
list[str]- A list of strings, each representing one grapheme cluster.
Building from Source
# Install build dependencies
pip install scikit-build-core pybind11
# Build and install
pip install .
# Run tests
pip install pytest
pytest python/tests/
License
MIT License
Metadata
Release files for grapheme-cluster-break 1.1.1
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 |
|---|---|---|---|---|
| grapheme_cluster_break-1.1.1.tar.gz | 46.2 kB | Without provenance | Details for grapheme_cluster_break-1.1.1.tar.gz |
Release files / grapheme_cluster_break-1.1.1.tar.gz
| Download URL | grapheme_cluster_break-1.1.1.tar.gz |
|---|---|
| Size | 46.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
196d9b18b37aac8bb5eba4aaf9dd350532204c141506794779568c8a5d24ce7a
|
|
BLAKE2b-256 checksum How to use checksums |
e34758a0f3d793816b4ee392a9a5e3d70ae8bbaa9589837b5fdfe563cbd370c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.20
|
Security for grapheme-cluster-break 1.1.1
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.