# Language Filter

> Language 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 列。

- Skill name: `language_filter`
- Category: [Documents](https://www.openparable.com/skill/documents/1)
- Source: https://github.com/cas-bigdatalab/piflow/blob/HEAD/workspace/skills/language_filter/SKILL.md
- Repository: cas-bigdatalab/piflow (541 GitHub stars when collected)

## SKILL.md

# language_filter 语种过滤

## 功能概述
- langdetect 识别语种，写入 detected_lang 列。
- 根据模式保留或剔除目标语种样本。

## 参数说明

| 参数 | 必填 | 默认值 | 说明 |
|------|------|--------|------|
| `--input_path` | 是 |  | 输入文件路径（支持CSV/TSV/Excel等） |
| `--output_path` | 是 |  | 输出文件路径（过滤后的文件） |
| `--target_lang` | 是 |  | 目标语种代码（如 zh, en, fr 等） |
| `--text_columns` | 否 |  | 用于检测的文本列，逗号分隔；不填默认全部字符串列 |
| `--mode` | 否 |  | keep=保留目标语种，drop=剔除目标语种，默认 keep |

## 使用方法
```bash
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`。
- 语言检测对极短文本可能不稳定，建议提供上下文较多的列或多列拼接。

---

Source: https://www.openparable.com/skill/documents/language-filter (OpenParable). Cite the canonical URL above.
