{"record":{"id":"ff320a75b9b14862","repo":"hankcs/HanLP","slug":"path","errorCode":null,"errorMessage":"{path}","messagePattern":"\\{path\\}","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"hanlp/utils/io_util.py","lineNumber":58,"sourceCode":"    if verbose:\n        src = TimingFileIterator(path)\n    else:\n        src = open(path, encoding='utf-8')\n    for line in src:\n        yield json.loads(line)\n    if not verbose:\n        src.close()\n\n\ndef make_debug_corpus(path, delimiter=None, percentage=0.1, max_samples=100):\n    files = []\n    if os.path.isfile(path):\n        files.append(path)\n    elif os.path.isdir(path):\n        files += [os.path.join(path, f) for f in os.listdir(path) if\n                  os.path.isfile(os.path.join(path, f)) and '.debug' not in f and not f.startswith('.')]\n    else:\n        raise FileNotFoundError(path)\n    for filepath in files:\n        filename, file_extension = os.path.splitext(filepath)\n        if not delimiter:\n            if file_extension in {'.tsv', '.conll', '.conllx', '.conllu'}:\n                delimiter = '\\n\\n'\n            else:\n                delimiter = '\\n'\n        with open(filepath, encoding='utf-8') as src, open(filename + '.debug' + file_extension, 'w',\n                                                           encoding='utf-8') as out:\n            samples = src.read().strip().split(delimiter)\n            max_samples = min(max_samples, int(len(samples) * percentage))\n            out.write(delimiter.join(samples[:max_samples]))\n\n\ndef path_join(path, *paths):\n    return os.path.join(path, *paths)\n\n","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/utils/io_util.py#L40-L76","documentation":"make_debug_corpus accepts either a single corpus file or a directory of files; anything else (nonexistent path, or a special file) raises FileNotFoundError with just the path.","triggerScenarios":"Calling make_debug_corpus(path) where path is neither os.path.isfile nor os.path.isdir — usually a typo, a missing mount, or a path with wrong casing/extension.","commonSituations":"Notebooks referencing relative paths from a changed cwd; data not yet downloaded; container volumes not mounted where expected.","solutions":["Verify the path exists and is a regular file or directory: os.path.exists(path) before the call.","If it is a symlink/special file, resolve with os.path.realpath or point directly at the target file.","Check cwd-relative vs absolute path mistakes in scripts and notebooks."],"exampleFix":"# before\nmake_debug_corpus('data/train.tsv')  # cwd changed\n# after\nmake_debug_corpus(os.path.abspath('data/train.tsv'))","handlingStrategy":"validation","validationCode":"import os\nassert os.path.exists(path), f'corpus path not found: {path}'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use absolute paths built from a project root variable.","Fail fast on missing inputs at CLI arg parsing."],"tags":["file-not-found","path","validation"],"backgroundTag":"file-path-not-found","analyzedSha":"ddb1299bddff079e447af52ec12549c50636bfa8","analyzedAt":"2026-08-27T03:36:54.287Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}