Skill Detail

Annotate Classical Chinese corpora with HanLP

Produce reviewable token, lemma, POS and dependency annotations for Classical Chinese passages with HanLP’s dedicated Ancient Chinese model.

Data Extraction & TransformationMulti-Framework
Data Extraction & Transformation Multi-Framework Security Reviewed
⭐ 36.5k GitHub stars
COPY SKILL INSTRUCTIONS (OPTIONAL)
npx skills add agentskillexchange/skills --skill annotate-classical-chinese-corpora-with-hanlp Copy
Uses the third-party skills CLI, not an ASE-owned installer. Check your agent’s compatibility. This copies instructions; complete the upstream tool setup below separately.
At a glance
Tools required
Python, pip, HanLP 2.1.1, compatible PyTorch environment, upstream Ancient Chinese model resources; optional GPU
Install & setup
Create an isolated Python environment; run python -m pip install hanlp==2.1.1 with a compatible PyTorch stack. Load hanlp.pretrained.mtl.KYOTO_EVAHAN_TOK_LEM_POS_UDEP_LZH; first load downloads model resources. Check model licensing before use and run the upstream two-sentence demo before processing operator data. No MCP server or hosted API is required.
Author
hankcs / HanLP contributors
Publisher
Community
Last updated
Oct 23, 2026
Quick brief

Use this workflow when a research or corpus-preparation agent must produce reviewable linguistic annotations for already transcribed Classical Chinese passages. Turn a bounded, operator-supplied batch into token, lemma, part-of-speech and dependency annotations using HanLP’s dedicated Ancient Chinese model.

How it works

What this skill actually does

Inputs and preparation

Obtain UTF-8 passages with stable document and sentence IDs, the requested output location, and a small manually checked sample. Preserve traditional/simplified characters and the original transcription. Do not silently modernize, translate or repair the text. Confirm that the intended use is compatible with the selected model’s license: upstream code is Apache-2.0, while pretrained models default to CC BY-NC-SA 4.0 unless otherwise specified. Commercial model use requires separately confirmed rights.

Install and invoke

In a dedicated Python environment install python -m pip install hanlp==2.1.1. Use a Python/PyTorch combination supported by the deployment environment. GPU acceleration is optional. The first model load downloads upstream model resources and can require substantial disk, memory and network access; arrange that before a restricted or offline run.

The v2.1.1 upstream demo loads the following model and parses a list of passages. This adaptation adds the documented JSON export method:

import hanlp
parser = hanlp.load(hanlp.pretrained.mtl.KYOTO_EVAHAN_TOK_LEM_POS_UDEP_LZH)
sentences = ['晋太元中,武陵人捕鱼为业。', '司馬牛問君子']
doc = parser(sentences)
print(doc.to_json())
doc.pretty_print()

Repeatable operator procedure

  1. Run the supplied two-sentence upstream example first. Confirm that the model loads and returns annotations; record any dependency or resource failure instead of substituting another language model.
  2. Run a small operator-approved sample, inspect the returned task keys, and compare fine/coarse tokenization and POS/dependency output against the hand-checked sample. HanLP’s demo also shows skip_tasks='tok/fine'; use that only when the requested annotation policy explicitly selects the alternative, and record the choice.
  3. Process the supplied sentence batches while retaining input order and an external mapping to the stable source IDs. Save each batch’s doc.to_json() output to the requested new artifact. Never overwrite the source transcription.
  4. Check sentence counts, token/tag alignment, and dependency references against the actual returned segmentation. Flag mismatches, missing tasks and uncertain segmentation for human review. Preserve raw annotations alongside any downstream conversion.
  5. Return the annotation artifacts, source-ID mapping, input counts, package version, exact model identifier, chosen tokenization policy, runtime/device details and an exceptions/sample-review report. Model predictions remain draft annotations.

Scope

This skill prepares and checks Classical Chinese corpus annotations. It does not perform OCR, translation, historical interpretation, model training, automatic fact extraction, or publication. It uses local Python inference, with initial resource downloads, and does not require the hosted HanLP API or an MCP server. Runtime compatibility and model accuracy must be checked on the operator’s sample; metadata verification is not a security review.

Upstream references

Release-pinned Ancient Chinese demo; model documentation; Document JSON export implementation; upstream project and license distinctions.