← all repositories
hankcs/pyhanlp

Your Chinese NLP pipeline, translated from Java

pyhanlp wraps the Java-based HanLP 1.x library so Python developers can segment, parse, and analyze Chinese text using algorithms already hardened in industry and academia.

3.2k stars Python Language Models
pyhanlp
Not currently ranked — collecting fresh signals.
star history

What it does

pyhanlp is essentially a Python front-end for HanLP 1.x, a widely used Java natural-language processing library. It exposes high-level Chinese text operations—word segmentation, part-of-speech tagging, named-entity recognition, dependency parsing, keyword extraction, and automatic summarization—through both a Python API and a command-line interface. Under the hood, it uses Java interop mechanisms like JClass to call into the underlying JVM library, meaning you are orchestrating Java classes from Python syntax.

The interesting bit

The project does not re-implement the algorithms; it acts as a diplomatic translator between ecosystems, letting Python developers tap into a library that has been tested in both academic and industrial settings. It also ships with an integrated HTTP server and an auto-updater for the HanLP 1.x core, turning a Java dependency into a self-managing runtime feature.

Key highlights

  • Wraps the full HanLP 1.x feature set: segmentation, POS tagging, NER, dependency parsing, text classification, sentiment analysis, and support for Taiwan/Hong Kong Traditional Chinese.
  • Exposes lower-level Java classes directly via JClass, SafeJClass, and LazyLoadingJClass for advanced users who need thread safety or deferred loading.
  • Includes a built-in HTTP server mode (hanlp serve) for local API access and an auto-updater to keep the Java backend current.
  • Companion book and runnable Jupyter notebooks are provided for learning the underlying NLP theory.
  • Cross-platform support covering Linux, macOS, and Windows across Python 3.6 through 3.13.

Caveats

  • Requires a Java runtime (OpenJDK) because the heavy lifting is done by the underlying HanLP 1.x JARs, not native Python code.
  • HanLP 2.x—a deep-learning, multilingual successor—has been available since early 2020 and runs in parallel; this wrapper targets the older 1.x branch specifically.

Verdict

Worth a look if you need proven, feature-rich Chinese NLP in a Python environment and do not mind a JVM lurking in the background. Skip it if you are already committed to HanLP 2.x or need a pure-Python stack with no Java dependency.

Frequently asked

What is hankcs/pyhanlp?
pyhanlp wraps the Java-based HanLP 1.x library so Python developers can segment, parse, and analyze Chinese text using algorithms already hardened in industry and academia.
Is pyhanlp open source?
Yes — hankcs/pyhanlp is open source, released under the Apache-2.0 license.
What language is pyhanlp written in?
hankcs/pyhanlp is primarily written in Python.
How popular is pyhanlp?
hankcs/pyhanlp has 3.2k stars on GitHub.
Where can I find pyhanlp?
hankcs/pyhanlp is on GitHub at https://github.com/hankcs/pyhanlp.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.