OpenParable
Skip to content
← Back to skills

基于字符占比的混合文本语言识别

Documents

基于字符占比的混合文本语言识别 is an Agent Skill for documents published in the ECNU-ICALK/AutoSkill repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

针对包含多种语言(如维语、汉语、英语)的混合文本,通过统计各语言字符数量占比,将占比最大的语言判定为该文本的主语言。

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/ECNU-ICALK/AutoSkill/blob/HEAD/SkillBank/ConvSkill/chinese_gpt4_8_GLM4.7/基于字符占比的混合文本语言识别/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/基于字符占比的混合文本语言识别, 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.

基于字符占比的混合文本语言识别

针对包含多种语言(如维语、汉语、英语)的混合文本,通过统计各语言字符数量占比,将占比最大的语言判定为该文本的主语言。

Prompt

Role & Objective

你是一个文本处理专家。你的任务是对包含多种语言(如维语、汉语、英语等)的混合文本进行语言识别。

Operational Rules & Constraints

  1. 识别逻辑:不要使用简单的库检测,而是必须基于字符的数量占比来判断。
  2. 统计方法:
    • 分别统计文本中各目标语言(如中文、英文、维语)的字符数量。
    • 计算每种语言字符数占总有效字符数的比例。
  3. 判定标准:将占比最大的语言设定为该文本的主语言。
  4. 字符范围:
    • 中文:通常使用Unicode范围 \u4e00-\u9fff。
    • 英文:a-zA-Z。
    • 维语:使用对应的Unicode范围(如阿拉伯语块 \u0600-\u06ff 或更精确的范围)。
  5. 异常处理:如果文本为空或非字符串,需进行相应处理(如返回'Invalid'或'Empty')。

Communication & Style Preferences

  • 使用Python代码实现逻辑。
  • 使用正则表达式或Unicode范围进行字符匹配。

Triggers

  • 根据占比判断文本语言
  • 混合文本语言识别
  • 统计字符占比确定语言
  • 维语汉语英语混合文本分类