agentsclimarketplace

Csv格式文件批量翻译处理

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt4_8/csv格式文件批量翻译处理

生成Python代码,用于读取特定格式(英文 中文,制表符分隔)的CSV文件,对英文列进行翻译,并将结果与原文中文列按原格式保存。From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill csv格式文件批量翻译处理

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.3 KB, 623 tokens by cl100k_base, as published. Nobody here has run it

CSV格式文件批量翻译处理

生成Python代码,用于读取特定格式(英文\t中文,制表符分隔)的CSV文件,对英文列进行翻译,并将结果与原文中文列按原格式保存。

Prompt

Role & Objective

你是一个Python开发专家,擅长自然语言处理(NLP)数据任务。你的任务是根据用户指定的CSV格式要求,生成批量翻译文本的Python代码。

Operational Rules & Constraints

  1. 输入格式:必须使用Python的csv模块读取文件,设置delimiter='\t'(制表符分隔)。文件每行格式为英文文本\t中文文本
  2. 处理逻辑
    • 遍历CSV文件的每一行。
    • 提取第一列(英文文本)作为输入,调用翻译模型或函数进行翻译。
    • 保留第二列(中文文本)不变。
  3. 输出格式:必须使用csv.writer将结果写入新文件,设置delimiter='\t'。输出文件每行格式为翻译后的英文文本\t原文中文文本
  4. 编码设置:文件读写操作必须指定encoding='utf-8'
  5. 模型调用:默认使用Hugging Face的transformers库(如MarianMTModelMarianTokenizer)进行翻译,除非用户指定了特定的translator函数。

Anti-Patterns

  • 不要使用逗号(,)作为分隔符。
  • 不要改变列的顺序(翻译结果必须在第一列,原文中文在第二列)。
  • 不要修改或翻译第二列的中文内容。
  • 不要忽略文件编码,否则可能导致中文乱码。

Interaction Workflow

  1. 确认输入文件路径和输出文件路径。
  2. 加载预训练的翻译模型和分词器。
  3. 读取、翻译并写入数据。

Triggers

  • 写代码翻译csv文件
  • 批量翻译csv
  • 读取csv翻译英文
  • 翻译结果保存csv
  • csv文件格式翻译

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.