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.

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.5-py3-none-manylinux_2_17_x86_64.whl (908.6 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

suzume-0.9.5-py3-none-macosx_11_0_arm64.whl (682.8 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for suzume-0.9.5-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 0797cdd1624ba91b78175698cade133577ebfff54d0e1f0ac9b47c6c9acaabe4
MD5 d37e06c05e5f93849ccee751d96f6e21
BLAKE2b-256 c3f6c1427b9cc7c2615afbd297c8487539b40bccd3a6e262c73a9c10da6e7feb

See more details on using hashes here.

Provenance

The following attestation bundles were made for suzume-0.9.5-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.5-py3-none-macosx_11_0_arm64.whl.

File metadata

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

File hashes

Hashes for suzume-0.9.5-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b5e8cb376b8f788832deca703436a79d95796fd3e8ed7173e886fe5d99729413
MD5 0490425d742d9dbbaae21d3b6cc13ba2
BLAKE2b-256 54a17d9d58bec070abd4e991a447ddd8c86d296e90831d428a0c061130066e2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for suzume-0.9.5-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