OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Developer Tools & SDKs

Pyhanlp

Pyhanlp is a Python interface to HanLP 1.x, a natural-language processing toolkit for Chinese text. It offers API access and a command-line tool for segmentation and parsing, alongside functions including keyword extraction, summarization, part-of-speech tagging, named-entity recognition, text classification and sentiment analysis.

Independent OpenViST project profile, based on linked sources.

Pyhanlp — OpenViST project profile in AI Developer Tools & SDKs.
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use Pyhanlp when a Python project needs access to HanLP 1.x capabilities for Chinese text, or when a command-line workflow is more convenient than calling the Python interface.

Who it is for

  • Python developers adding Chinese-language analysis to text-processing applications.
  • Practitioners who need command-line segmentation or dependency parsing.
  • Learners exploring NLP tasks through the repository's examples and companion code.

Documented uses

  • Segment Chinese text and inspect part-of-speech labels.
  • Parse dependency relations in a sentence.
  • Extract keywords or generate an automatic summary.
  • Call HanLP functionality from Python and, when needed, access lower-level Java classes.
Before you choose

Requirements & limits

The repository identifies the project as open source under the Apache-2.0 license.

  • The interface targets HanLP 1.x; the README describes HanLP 2.x as a separate, parallel project.
  • The documented installation path installs OpenJDK and Python through conda before installing Pyhanlp with pip.
  • The README specifies Python 3.6 or later compatibility and lists Linux, macOS and Windows support.
  • Lower-level analyzer access uses Java class paths through JClass, rather than only the common Python convenience interface.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Install Pyhanlp with conda and pip

Prepare the documented Python and Java prerequisites and install the Pyhanlp package.

Before you start

  • Conda
  • OpenJDK
  • Python 3.8

Steps

  1. Install OpenJDK and Python 3.8 from conda-forge using the README's conda command.

  2. Install Pyhanlp with pip.

  3. Run the hanlp command to check the installation.

Expected outcome

The package is installed and the documented command-line check can be run.

Guide limitations

  • The README notes that automatic setup may fail because of network or other issues and points to manual configuration and a Windows guide.
Source-based practical guide

Segment Chinese text with the command line

Use the documented interactive segmentation command to obtain segmented output.

Before you start

  • An installed Pyhanlp environment with the hanlp command available

Steps

  1. Run hanlp segment.

  2. Enter a Chinese sentence and press return.

  3. Read the segmentation result and its displayed part-of-speech labels.

Expected outcome

HanLP 1.x returns segmented text in the command-line session.

Guide limitations

  • This recipe covers the documented interactive workflow; the README also describes redirected input and output separately.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
15 October 2026
Original website title
hankcs/pyhanlp · Official homepage title · retained in its source language