Skip to main content

Lightweight dictionary-independent Japanese morphological analyzer

Project description

suzume

PyPI License Python

Lightweight, dictionary-independent Japanese morphological analyzer (tokenizer + part-of-speech tagging). This package is a thin ctypes binding over the native suzume C++ core; the compiled library and dictionaries are bundled in the wheel, so there is nothing else to install.

Full documentation: suzume.libraz.net/docs/python.

Installation

pip install suzume

Quick start

from suzume import Suzume

with Suzume() as sz:
    for m in sz.analyze("東京都に住む"):
        print(m.surface, m.pos, m.base_form)

Generate keyword tags:

from suzume import Suzume

with Suzume() as sz:
    for tag in sz.generate_tags("東京都に住んでいます"):
        print(tag.tag, tag.pos)

    # Restrict to selected parts of speech by name (or a raw bitmask).
    nouns = sz.generate_tags("美味しいラーメンを食べた", pos_filter=["noun"])

API

Suzume(*, mode="normal", preserve_vu=True, preserve_case=True, preserve_symbols=False, lemmatize=True, merge_compounds=False)

An analyzer instance. Use it as a context manager (or call close()); it is not thread-safe, so use one instance per thread.

  • mode"normal", "search", or "split" (or a Mode enum member).
  • analyze(text) -> list[Morpheme] — tokenize with full POS information.
  • generate_tags(text, **options) -> list[Tag] — extract keyword tags. The pos_filter option accepts a raw bitmask (1=noun, 2=verb, 4=adjective, 8=adverb) or an iterable of POS names such as ["noun", "verb"].
  • load_user_dict(csv) — add a user dictionary from CSV text.
  • load_binary_dict(data) — load a compiled .dic dictionary from memory.
  • dictionary_warnings — warnings raised while auto-loading dictionaries.

Morpheme

A frozen dataclass with surface, pos, base_form, pos_ja, conj_type, conj_form, extended_pos, start, end, the is_* flags, and score. conj_type and conj_form are None for non-conjugating words.

Tag

A frozen dataclass with tag and pos.

suzume.version()

Returns the native library version string.

License

Apache-2.0. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

suzume-0.9.6-py3-none-manylinux_2_17_x86_64.whl (675.8 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

suzume-0.9.6-py3-none-macosx_11_0_arm64.whl (490.9 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file suzume-0.9.6-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for suzume-0.9.6-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 176475301d95f3f6470dc1e07d92e0928c5704f85ab8e544d4824ba85e1508fb
MD5 38a2b22a3e8fea16dd7b02cb314fb2f0
BLAKE2b-256 007b7315ead4594d57f36a94b188f54ae9e715f19d2dc2fc2411a206adfe0fdf

See more details on using hashes here.

Provenance

The following attestation bundles were made for suzume-0.9.6-py3-none-manylinux_2_17_x86_64.whl:

Publisher: publish.yml on libraz/suzume

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file suzume-0.9.6-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: suzume-0.9.6-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 490.9 kB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for suzume-0.9.6-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c7eff8421650222da3e014667ac32b828d1133c9c10d848ef52794ba5a0e24d1
MD5 c4b3766fc95df7fa209ed1fac22652eb
BLAKE2b-256 9f31c9e2e2d9c32c7cb533b2e07809f996818c4da854545ab77d0599acbdb5bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for suzume-0.9.6-py3-none-macosx_11_0_arm64.whl:

Publisher: publish.yml on libraz/suzume

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page