Skip to main content

rhoknp logo

rhoknp: Yet another Python binding for Juman++/KNP/KWJA

Test Codecov CodeFactor PyPI PyPI - Python Version Documentation Ruff


Documentation: https://rhoknp.readthedocs.io/en/latest/

Source Code: https://github.com/ku-nlp/rhoknp


rhoknp is a Python binding for Juman++, KNP, and KWJA.1

import rhoknp

# Perform morphological analysis by Juman++
jumanpp = rhoknp.Jumanpp()
sentence = jumanpp.apply_to_sentence("電気抵抗率は電気の通しにくさを表す物性値である。")

# Access to the result
for morpheme in sentence.morphemes:  # a.k.a. keitai-so
    ...

# Save the result
with open("result.jumanpp", "wt") as f:
    f.write(sentence.to_jumanpp())

# Load the result
with open("result.jumanpp", "rt") as f:
    sentence = rhoknp.Sentence.from_jumanpp(f.read())

Requirements

  • Python 3.10+
  • (Optional) Juman++ v2.0.0-rc3+
  • (Optional) KNP 5.0+
  • (Optional) KWJA 1.0.0+

Installation

pip install rhoknp

Quick tour

Let's begin by using Juman++ with rhoknp. Here, we present a simple example demonstrating how Juman++ can be used to analyze a sentence.

# Perform morphological analysis by Juman++
jumanpp = rhoknp.Jumanpp()
sentence = jumanpp.apply_to_sentence("電気抵抗率は電気の通しにくさを表す物性値である。")

You can easily access the individual morphemes that make up the sentence.

for morpheme in sentence.morphemes:  # a.k.a. keitai-so
    ...

Sentence objects can be saved in the JUMAN format.

# Save the sentence in the JUMAN format
with open("sentence.jumanpp", "wt") as f:
    f.write(sentence.to_jumanpp())

# Load the sentence
with open("sentence.jumanpp", "rt") as f:
    sentence = rhoknp.Sentence.from_jumanpp(f.read())

Almost the same APIs are available for KNP.

# Perform language analysis by KNP
knp = rhoknp.KNP()
sentence = knp.apply_to_sentence("電気抵抗率は電気の通しにくさを表す物性値である。")

KNP performs language analysis at multiple levels.

for clause in sentence.clauses:  # a.k.a., setsu
    ...
for phrase in sentence.phrases:  # a.k.a. bunsetsu
    ...
for base_phrase in sentence.base_phrases:  # a.k.a. kihon-ku
    ...
for morpheme in sentence.morphemes:  # a.k.a. keitai-so
    ...

Sentence objects can be saved in the KNP format.

# Save the sentence in the KNP format
with open("sentence.knp", "wt") as f:
    f.write(sentence.to_knp())

# Load the sentence
with open("sentence.knp", "rt") as f:
    sentence = rhoknp.Sentence.from_knp(f.read())

Furthermore, rhoknp provides convenient APIs for document-level language analysis.

document = rhoknp.Document.from_raw_text("電気抵抗率は電気の通しにくさを表す物性値である。単に抵抗率とも呼ばれる。")
# If you know sentence boundaries, you can use `Document.from_sentences` instead.
document = rhoknp.Document.from_sentences(
    [
        "電気抵抗率は電気の通しにくさを表す物性値である。",
        "単に抵抗率とも呼ばれる。",
    ]
)

Document objects can be handled in a similar manner as Sentence objects.

# Perform morphological analysis by Juman++
document = jumanpp.apply_to_document(document)

# Access language units in the document
for sentence in document.sentences:
    ...
for morpheme in document.morphemes:
    ...

# Save language analysis by Juman++
with open("document.jumanpp", "wt") as f:
    f.write(document.to_jumanpp())

# Load language analysis by Juman++
with open("document.jumanpp", "rt") as f:
    document = rhoknp.Document.from_jumanpp(f.read())

For more information, please refer to the examples and documentation.

Main differences from pyknp

pyknp serves as the official Python binding for Juman++ and KNP. In the development of rhoknp, we redesigned the API, considering the current use cases of pyknp. The key differences between the two are as follows:

  • Support for document-level language analysis: rhoknp allows you to load and instantiate the results of document-level language analysis, including cohesion analysis and discourse relation analysis.
  • Strict type-awareness: rhoknp has been thoroughly annotated with type annotations, ensuring strict type checking and improved code clarity.
  • Comprehensive test suite: rhoknp is extensively tested with a comprehensive test suite. You can view the code coverage report on Codecov.

License

MIT

Contributing

We warmly welcome contributions to rhoknp. You can get started by reading the contribution guide.

Reference

  1. The logo was generated by OpenAI DALL·E 2. ↩

Metadata

Release files for rhoknp 1.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rhoknp 1.8.1
File Size Uploaded
rhoknp-1.8.1.tar.gz 67.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rhoknp 1.8.1
File Interpreter ABI Platform
rhoknp-1.8.1-py3-none-any.whl Python 3 none any Details

Total release size: 162.2 kB

Release files / rhoknp-1.8.1.tar.gz

Download URL rhoknp-1.8.1.tar.gz
Size 67.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b767c541a1f6ff9f09a3a8096dd4217b8a138fd3896e69fe799989d50cf1d423
BLAKE2b-256 checksum
How to use checksums
8afcee75121b4b4de895052b796ac30d723499de5a329298d3ed513481a0f8ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.

Transparency log

Release files / rhoknp-1.8.1-py3-none-any.whl

Download URL rhoknp-1.8.1-py3-none-any.whl
Size 94.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2fb54b7e882c19d8d545256c798a567179b7697c053a90f443b7083ad3e677ad
BLAKE2b-256 checksum
How to use checksums
592bf6822bfbc164e00ee5e0a96e58461b651da1dbc12a82f25f7e11e8421c50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.8.1 This release

2 release files

1.8.0

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.0

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page