Registry / ai-ml / tinysegmenter

tinysegmenter

JSON →
library0.4pypypi✓ verified 23d ago

TinySegmenter in Python is a Python port of the original JavaScript-based TinySegmenter, an extremely compact (23KB) Japanese tokenizer. It offers character-based segmentation with approximately 95% precision for Japanese news articles, compatible with MeCab + IPADic segmentation units, without relying on external dictionaries. The latest version, 0.4, was released on September 16, 2018, and its development is not actively maintained, though contributions are welcome.

pip install tinysegmenter
INSTALL
IMPORT
SIG · TINYSEGMENTER
T
tinysegmenter
ai-mlpythonv0.4
Install
2.4s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.4s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TinySegmenter
from tinysegmenter import TinySegmenter
import tinysegmenter; segmenter = tinysegmenter.segmenter.TinySegmenter()
The class is directly available under the 'tinysegmenter' module, not a nested submodule.

Initialize the TinySegmenter and tokenize a Japanese string into a list of words.

import tinysegmenter segmenter = tinysegmenter.TinySegmenter() text = "私の名前は中野です" tokens = segmenter.tokenize(text) print(' | '.join(tokens)) # Expected output: 私 | の | 名前 | は | 中野 | です
Debug
Known issues
gotchaThe project is explicitly stated by its maintainer as not being actively developed, with limited maintenance. New features or rapid bug fixes are unlikely.
fix
Be aware of the project's maintenance status. For active development or critical projects, consider forks like 'tinysegmenter3' or more actively maintained Japanese tokenizers.
affects: 0.4 and later (if any)
gotchaAs a 'very compact' tokenizer, TinySegmenter makes trade-offs in accuracy and performance compared to larger, more sophisticated Japanese NLP libraries. While suitable for lightweight tasks, it might not offer the highest precision or speed for complex or large-scale Japanese text processing.
fix
For higher accuracy or performance requirements, evaluate alternative Japanese tokenizers such as MeCab, Sudachi, or Janome. Benchmarking with your specific data is recommended.
affects: All versions
gotchaAlthough the `tinysegmenter` 0.4 package states compatibility with Python 3, a prominent fork named `tinysegmenter3` exists specifically to provide improved Python 3 compatibility and enhanced performance. This implies that the original `tinysegmenter` might not be fully optimized or as robust for modern Python 3 environments as its dedicated Python 3 fork.
fix
If working with Python 3, especially for performance-sensitive applications, consider using `tinysegmenter3` (`pip install tinysegmenter3`) or another Python 3 native Japanese tokenizer for potentially better results.
affects: 0.4 on Python 3.x
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'tinysegmenter'
The 'tinysegmenter' library has not been installed in the current Python environment, or the script is being run with a different Python interpreter than the one where the library was installed.
fix
pip install tinysegmenter
AttributeError: module 'tinysegmenter' has no attribute 'segment'
The 'segment' method is part of the 'TinySegmenter' class, and the user is attempting to call it directly from the 'tinysegmenter' module without first creating an instance of the class.
fix
import tinysegmenter
segmenter = tinysegmenter.TinySegmenter()
text = "吾輩は猫である"
tokens = segmenter.segment(text)
TypeError: 'module' object is not callable
The user is attempting to call the 'tinysegmenter' module itself as if it were a function, instead of instantiating the 'TinySegmenter' class within it.
fix
import tinysegmenter
segmenter = tinysegmenter.TinySegmenter() # Correctly instantiates the class
text = "吾輩は猫である"
tokens = segmenter.segment(text)
ImportError: cannot import name 'segment' from 'tinysegmenter'
The 'segment' method is an instance method of the 'TinySegmenter' class, not a top-level function directly available for import from the 'tinysegmenter' module.
fix
from tinysegmenter import TinySegmenter # Import the class
segmenter = TinySegmenter()             # Instantiate the class
text = "吾輩は猫である"
tokens = segmenter.segment(text)
Upgrade
Version history
0.4latest on PyPI · released Sep 16, 2018
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
12
OpenAI (training)
1
Resources
tinysegmenter — pip install tinysegmenter · libregistry