hankcs/HanLP · critical · FileNotFoundError
Chinese Treebank 9.0 is a copyright dataset owned by LDC whi
Error message
Chinese Treebank 9.0 is a copyright dataset owned by LDC which we cannot re-distribute. Please apply for a licence from LDC (https://catalog.ldc.upenn.edu/LDC2016T13) then download it to {path_from_url(_CTB9_HOME)} What it means
At import time, hanlp.datasets.parsing.ctb9 tries to fetch the CTB9 dataset home and, on HTTPError (the data is not hosted), raises FileNotFoundError explaining that CTB 9.0 is LDC-licensed and cannot be redistributed. The message tells you to obtain an LDC licence and manually place the corpus at the shown local path.
Source
Thrown at hanlp/datasets/parsing/ctb9.py:49
CTB9_BRACKET_LINE_NOEC_TRAIN = _CTB9_HOME + 'tasks/par/train.noempty.txt'
'''Training set for ctb9 constituency parsing without empty categories.'''
CTB9_BRACKET_LINE_NOEC_DEV = _CTB9_HOME + 'tasks/par/dev.noempty.txt'
'''Dev set for ctb9 constituency parsing without empty categories.'''
CTB9_BRACKET_LINE_NOEC_TEST = _CTB9_HOME + 'tasks/par/test.noempty.txt'
'''Test set for ctb9 constituency parsing without empty categories.'''
CTB9_SD330_TRAIN = _CTB9_HOME + 'tasks/dep/train.conllx'
'''Training set for ctb9 in Stanford Dependencies 3.3.0 standard.'''
CTB9_SD330_DEV = _CTB9_HOME + 'tasks/dep/dev.conllx'
'''Dev set for ctb9 in Stanford Dependencies 3.3.0 standard.'''
CTB9_SD330_TEST = _CTB9_HOME + 'tasks/dep/test.conllx'
'''Test set for ctb9 in Stanford Dependencies 3.3.0 standard.'''
try:
get_resource(_CTB9_HOME)
except HTTPError:
raise FileNotFoundError(
'Chinese Treebank 9.0 is a copyright dataset owned by LDC which we cannot re-distribute. '
f'Please apply for a licence from LDC (https://catalog.ldc.upenn.edu/LDC2016T13) '
f'then download it to {path_from_url(_CTB9_HOME)}'
)
make_ctb(_CTB9_HOME)
View on GitHub (pinned to ddb1299bdd)
Solutions
- Apply for an LDC licence (LDC2016T13) and download CTB9
- Copy/extract the corpus to the path shown in the message (path_from_url(_CTB9_HOME) — typically your HANLP data dir) and re-run
- Alternatively use an open Chinese treebank/dataset supported by HanLP if licensing CTB is not an option
Example fix
# shell: after obtaining CTB9 from LDC mkdir -p ~/hanlp/ctb9 cp -r /path/to/ctb9/* ~/hanlp/ctb9/ # then re-run your script
Defensive patterns
Strategy: validation
Validate before calling
from hanlp.utils.io_util import path_from_url
from os.path import exists
ctb_home = path_from_url('http://nlp.ee.polyu.edu.hk/releases/ctb9/') # or reuse _CTB9_HOME
if not exists(ctb_home):
raise SystemExit(f'CTB9 corpus missing at {ctb_home}. Obtain LDC2016T13 and place it there.') Try / catch
try:
import hanlp.datasets.parsing.ctb9 # noqa
except FileNotFoundError as e:
print(e) # show licence/placement instructions
sys.exit(1) Prevention
- Pre-download licensed corpora to the HanLP data dir before importing dataset modules
- Automate environment provisioning so licensed data presence is checked at deploy time
When it happens
Trigger: import hanlp.datasets.parsing.ctb9 (or a pipeline that pulls it in) without the CTB9 corpus already at the expected local path; the download attempt gets an HTTP error instead of data.
Common situations: Fresh machines/environments; assuming HanLP auto-downloads all datasets like it does for open ones; new users unaware CTB is paid LDC data.
Related errors
- Got average f{average}, expected one of None, 'token', or 'b
- alpha must be float, list of float, or torch.FloatTensor, {}
- Only supports floating point dtypes.
- Does not support dtype " + str(dtype)
- activation must be callable: type={}
AI-assisted analysis of hankcs/HanLP@ddb1299bdd (2026-08-27).
Data as JSON: /api/errors/c23b9799b47383f5.
Report an issue: GitHub.