13 / 90

学习日 13:文本与数据学习项目

将现有的 text_tools 项目变成一条可复现的语料到产物的流水线。

自主学习与 Python 480 分钟(8 小时专注学习)
01 120 分钟

构建 CLI 核心

只有在记录预测之后才允许智能体协助;必须检查并测试每一处生成的差异。

先决条件

第 01–12 天:字符串、字典、文件、异常、测试与终端使用。

学习目标

实现或检查 projects/text_tools/core.py 与 cli.py,覆盖统计、确定性分割、出处清单(manifest)以及显式的编码错误。

操作说明

必做:先创建本练习专用的私有工作区(WORKDIR=$(mktemp -d)),把小型语料写入 $WORKDIR/corpus.txt,记录预测,然后运行完整调用 python3 projects/text_tools/cli.py --input "$WORKDIR/corpus.txt" --stats --json --split --output-dir "$WORKDIR/artifacts";检查差异,并逐一练习 --input、--stats、--split、--output-dir、--seed、--encoding 和 --errors。选做:对比 Python 文档链接。

练习与预测

使用一个包含重复词元、中日韩文字、带重音字符和一个表情符号的小型语料库。先预测字符数/词元数,然后验证 stats.json 和 manifest.json——包括 source_sha256 与原始输入字节的 SHA256(如 sha256sum "$WORKDIR/corpus.txt")一致,且 input_decoding 记录了编码、错误处理与换行策略。

Learning Project Submission & Evidence

0 / 4096 字节
Declared Assistance Condition

Current Submitted Evidence Details

No submission recorded yet.
独立掌握标准

学习者能够讲解并运行真实的 text_tools CLI,记录预测与证据,且不会把智能体写出的差异当作独立理解的证明。

来源资源与出处

linking PSF License Version 2

Python Standard Library: Built-in Types

作者 / 机构: Python Software Foundation | 原始出处链接 ↗

对应章节 / 时间戳: str methods and Unicode semantics used by analyze_text (split, join, isalpha, isdigit)

验证版本与日期: Python 3.12 documentation; verified 2026-10-30

入选理由:

Primary reference for the string methods and Unicode semantics behind corpus statistics.

来源前置条件:

Study Days 01–12 Python fundamentals

安全回退方案(离线弹性):

The lesson explains all required behavior locally and the reference implementation ships in the repository; pydoc mirrors the same documentation offline.

对比候选资源与选型分析 (2)
GNU coreutils wc/split ↗ compared_rejected_for_day13 [GPL-3.0-or-later]

Powerful system tools, but the learning target is implementing and testing the behavior in Python, not delegating to platform-specific utilities.

Python HOWTO: Unicode ↗ compared_alternative [PSF License Version 2]

Deeper Unicode background for the encoding edge cases; str method reference remains the primary doc.

linking PSF License Version 2

argparse — Parser for command-line options, arguments and subcommands

作者 / 机构: Python Software Foundation | 原始出处链接 ↗

对应章节 / 时间戳: add_argument flags, choices, and type conversion used by cli.py

验证版本与日期: Python 3.12 documentation; verified 2026-10-30

入选理由:

Primary reference for the CLI flags the learner exercises on the real project.

来源前置条件:

Study Days 01–12 Python fundamentals

安全回退方案(离线弹性):

argparse is part of the standard library; python3 -c "import argparse; help(argparse)" works fully offline.

对比候选资源与选型分析 (2)
Click package documentation ↗ compared_rejected_for_day13 [BSD-3-Clause]

Strong third-party CLI framework, but the project intentionally uses only the standard library so the exercise needs no extra dependency.

docopt ↗ compared_rejected_for_day13 [MIT]

Usage-string DSL for CLIs, but an external dependency is unjustified when argparse covers the project.

02 120 分钟

独立实现核心

独立掌握检查:不允许 AI、抄写答案或智能体生成的代码。

先决条件

完成第 13 天活动 1,并关闭所有参考标签页。

学习目标

在无 AI 协助的情况下,按照真实项目接口实现一个有边界的统计或分割函数。

操作说明

必做:独立实现且只实现一个被评估接口并声明所选——analyze_text(text) -> dict(统计)或 compute_splits(lines, train_ratio, val_ratio, test_ratio, seed) -> dict(切分);然后在一个“你事先预测结果的、不同的新无协助输入”上测试。选做:提交后再与参考对照。正典示例输出是公开参考,绝非隐藏评估。

练习与预测

选择一个被评估接口并声明。路线 A analyze_text(text) -> dict:预测输入 'a a\n猫🙂' 的完整结果——键为 total_chars、total_tokens、vocab_size、char_vocab_size、token_frequencies、char_frequencies、min_token_length、max_token_length、avg_token_length、char_distribution。路线 B compute_splits(lines, train_ratio, val_ratio, test_ratio, seed) -> dict:对 ['a','b','c','d','e']、种子 7、比例 .6/.2/.2,预测计数并证明索引集合两两不相交。并说明所选路线依赖的区分规则(B:相同文本值仍需索引级检查;A:相同文本值不会虚增词表)。

独立掌握标准

独立代码在不同的新无协助输入上通过留出行为检查,书面解释能区分索引泄漏、重复记录、token/字符计数与评估局限。

来源资源与出处

original_explanation Apache-2.0 AND CC-BY-SA-4.0 share-alike

Text and Data Tools Learning Project

作者 / 机构: Curriculum team (delivered in Ticket 16) | 原始出处链接 ↗

对应章节 / 时间戳: projects/text_tools/core.py: analyze_text and compute_splits interfaces

验证版本与日期: Verified against the checked-in implementation on 2026-10-30

入选理由:

The actual project whose interfaces the learner re-implements independently, keeping the exercise tied to real artifacts.

来源前置条件:

Study Days 01–12 Python fundamentals

安全回退方案(离线弹性):

The implementation and its project manifest are committed in the repository and work offline.

对比候选资源与选型分析 (2)
External toy CLI tutorials ↗ compared_rejected_for_day13 [PSF License Version 2]

Generic tutorials duplicate earlier days and disconnect the exercise from the deterministic data artifacts later experiments reuse.

CPython Lib/string.py reference implementation ↗ compared_alternative [PSF License Version 2]

Production string-tooling internals are instructive but heavier than the project's focused interfaces.

03 120 分钟

留出行为检查与调试

智能体协助的工程检查:指挥智能体、检查差异,然后亲自运行留出检查。

先决条件

已有独立实现的函数,以及一个干净的临时输出目录。

学习目标

在不改动课程仓库的前提下诊断真实故障:输入缺失、UTF-8 损坏、空输入、非法比例以及非确定性排序。

操作说明

必做:在进程隔离的临时目录中运行每个调试用例,记录退出状态和标准错误,并用留出数据重新生成产物。选做:让智能体提出测试建议,然后拒绝不安全或同义反复的测试。

练习与预测

留出行为检查使用空文件、损坏字节、多语言行和相同种子连跑两次。预测哪些调用会成功、哪些会失败、哪些产物字节必须一致。

Learning Project Submission & Evidence

0 / 4096 字节
Declared Assistance Condition

Current Submitted Evidence Details

No submission recorded yet.
独立掌握标准

证据包含命令、退出码、观察到的输出,以及至少三个案例的诊断和修复说明;不把子进程通过等同于掌握。

来源资源与出处

original_explanation Apache-2.0 AND CC-BY-SA-4.0 share-alike

Text and Data Tools Learning Project

作者 / 机构: Curriculum team (delivered in Ticket 16) | 原始出处链接 ↗

对应章节 / 时间戳: cli.py error paths: missing input, strict decoding, --output-dir requirement, ratio validation

验证版本与日期: Verified against the checked-in implementation on 2026-10-30

入选理由:

Held-out debugging must target the real CLI seams and exit codes, not a simplified re-implementation.

来源前置条件:

Study Days 01–12 Python fundamentals

安全回退方案(离线弹性):

All debugging cases run on a temporary corpus in a disposable directory with no external services.

对比候选资源与选型分析 (2)
External debugging courses ↗ compared_alternative [PSF License Version 2]

pdb documentation is a useful secondary reference, but the held-out cases exercise CLI behavior end to end.

pytest documentation ↗ compared_alternative [MIT]

Natural next step to formalize the held-out cases; the activity first exercises the CLI seams directly.

04 120 分钟

项目报告:假设与局限

独立掌握检查:先提交并封存未受协助的报告;之后的 AI 文字润色是单独标记、不计评估的产物,绝不替代独立证据。

先决条件

完成前面三个活动并保留其证据。

学习目标

撰写一份简短报告,把确定性数据准备与后续分词器和模型实验联系起来,同时说明假设与局限。

操作说明

必做:先撰写并封存(提交、注明日期)无协助的报告——覆盖来源归属、编码、词元定义、分割比例/种子、泄漏策略、观测到的测量值、可复现性和局限。之后的协助润色是单独标记的产物,不替代已封存版本;若协助暴露出实质缺漏,必须先做一次新的无协助检查方可计入掌握。选做:在不改动本项目的情况下提出一个后续分词器实验。

练习与预测

解释为什么固定的训练/验证/测试产物可以被 Makemore、minbpe 和 NanoGPT 复用,以及为什么固定分割并不能证明模型泛化。

独立掌握标准

报告完整,引用真实的项目产物,列出至少三条假设和三条局限,并能区分已封存的无协助草稿与单独标记的协助润色稿。

来源资源与出处

original_explanation Apache-2.0 AND CC-BY-SA-4.0 share-alike

Text and Data Tools Learning Project

作者 / 机构: Curriculum team (delivered in Ticket 16) | 原始出处链接 ↗

对应章节 / 时间戳: manifest.json fields: source_sha256, split ratios/counts/hashes, leakage_check, environment, created_at

验证版本与日期: Verified against the checked-in implementation on 2026-10-30

入选理由:

The report must cite the real manifest and artifacts the learner generated, preserving attribution to the project.

来源前置条件:

Study Days 01–12 Python fundamentals

安全回退方案(离线弹性):

Report evidence consists of local artifacts and command output captured in earlier activities.

对比候选资源与选型分析 (2)
Google Technical Writing One ↗ compared_alternative [CC BY 4.0 (course content)]

Solid general technical-writing training, but the report rubric here is specific to the project's manifest fields and provenance.

Write the Docs: Beginner's guide to documentation ↗ compared_alternative [CC BY-NC-SA 4.0]

General documentation guidance; the report rubric remains bound to this project's manifest fields.