- 1. Modules
- 2. Sample scripts
A Python package to determine Unicode text segmentations.
You can see the full documentation including the package reference on http://uniseg-python.readthedocs.io.
This package provides:
- Functions to get Unicode Character Database (UCD) properties concerned with text segmentations.
- Functions to determine segmentation boundaries of Unicode strings.
- Classes that help implement Unicode-aware text wrapping on both console (monospace) and graphical (monospace / proportional) font environments.
Supporting segmentations are:
- code point
- Code point is “any value in the Unicode codespace.” It is the basic unit for processing Unicode strings.
- grapheme cluster
- Grapheme cluster approximately represents “user-perceived character.” They may be made up of single or multiple Unicode code points. e.g. “G” + acute-accent is a user-perceived character.
- word break
- Word boundaries are familiar segmentation in many common text operations. e.g. Unit for text highlighting, cursor jumping etc. Note that words are not determinable only by spaces or punctuations in text in some languages. Such languages like Thai or Japanese require dictionaries to determine appropriate word boundaries. Though the package only provides simple word breaking implementation which is based on the scripts and doesn’t use any dictionaries, it also provides ways to customize its default behavior.
- sentence break
- Sentence breaks are also common in text processing but they are more contextual and less formal. The sentence breaking implementation (which is specified in UAX: Unicode Standard Annex) in the package is simple and formal too. But it must be still useful in some usages.
- line break
- Implementing line breaking algorithm is one of the key features of this package. The feature is important in many general text presentations in both CLI and GUI applications.
- Python 2.7 / 3.4 / 3.5 / 3.6
% pip install uniseg
or download the archive and:
% python setup.py install
- 0.7.1 (2015-05-02)
- CHANGE: wrap.Wrapper.wrap(): returns the count of lines now.
- Separate LICENSE from README.txt for the packaging-related reason in some environments.
- 0.7.0 (2015-02-27)
- CHANGE: Quitted gathering all submodules’s members on the top, uniseg module.
- CHANGE: Reform
uniseg.wrapmodule and sample scripts.
- Maintained uniseg.wrap module, and sample scripts work again.
- 0.6.4 (2015-02-10)
uniseg-dbpathconsole command, which just print the path of
- Include sample scripts under the package’s subdirectory.
- 0.6.3 (2015-01-25)
- Python 3.4
- Support modern setuptools, pip and wheel.
- 0.6.2 (2013-06-09)
- Python 3.3
- 0.6.1 (2013-06-08)
- Unicode 6.2.0
The MIT License (MIT) Copyright (c) 2013 Masaaki Shibata Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(This is the output of the sample script,
uniwrap.py with the option