Language Filter
Documentslanguage_filterLanguage Filter is an Agent Skill for documents published in the cas-bigdatalab/piflow repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
语种过滤工具。对指定或全部文本列进行语言检测,可选择保留或剔除目标语种, 输出过滤后的数据并附带 detected_lang 列。
QUICK START
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/cas-bigdatalab/piflow/blob/HEAD/workspace/skills/language_filter/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/language-filter, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
language_filter 语种过滤
功能概述
- langdetect 识别语种,写入 detected_lang 列。
- 根据模式保留或剔除目标语种样本。
参数说明
| 参数 | 必填 | 默认值 | 说明 |
|---|---|---|---|
--input_path | 是 | 输入文件路径(支持CSV/TSV/Excel等) | |
--output_path | 是 | 输出文件路径(过滤后的文件) | |
--target_lang | 是 | 目标语种代码(如 zh, en, fr 等) | |
--text_columns | 否 | 用于检测的文本列,逗号分隔;不填默认全部字符串列 | |
--mode | 否 | keep=保留目标语种,drop=剔除目标语种,默认 keep |
使用方法
python scripts/language_filter.py \
--input_path <输入文件> \
--output_path <输出文件> \
--target_lang zh \
[--text_columns col1,col2] \
[--mode keep|drop]
输出说明
- 新增列 detected_lang 标记检测结果。
- 根据 mode 输出过滤后的数据。
注意事项
- 依赖 langdetect,请确保已安装:
pip install langdetect。 - 语言检测对极短文本可能不稳定,建议提供上下文较多的列或多列拼接。