Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

BUG ColloquialWordswapConverter skips words next to punctuation and inserts spaces into hyphenated words

已关闭 适合新手
#3,131 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@ShivamSharma43 已经在做这个了。

开始于 2026年10月11日。

  • #3133 来自 @ShivamSharma43 —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
backend

调研方向

在 PyRIT converter 包中找到 ColloquialWordswapConverter,并阅读其分词和空格处理逻辑,以及现有的 test_awkward_spacing 测试。复现 issue 中的示例,并查看相邻的 converter 测试,了解预期的单词互换。完成标准是:标点符号和带连字符的单词保留原有的书写间距,同时符合条件的单词会被互换,并且现有的空白规范化仍然通过。

由索引模型根据 Issue 内容生成。

描述

Describe the bug

ColloquialWordswapConverter tokenizes with re.findall(r"\w+|\S+", prompt), rejoins every token with a space, and then removes the space before ?.!,'". That loses or changes text in a few common cases:

  • A word that starts after punctuation is never swapped, because \S+ takes the whole run, e.g. (father) or "mother".
  • A space is inserted inside hyphenated words: e-mail becomes e -mail, father-in-law becomes papa -in-law.
  • The clean-up regex removes a space the user wrote: a 'quoted' word becomes a'quoted' word.

To Reproduce

import asyncio
from pyrit.converter import ColloquialWordswapConverter

c = ColloquialWordswapConverter(deterministic=True)
for s in ["Ask (father) first.", '"mother" said hi', "My father-in-law called.", "e-mail your brother", "a 'quoted' word"]:
    print(repr(s), "->", repr(asyncio.run(c.convert_async(prompt=s)).output_text))
'Ask (father) first.' -> 'Ask (father) first.'
'"mother" said hi' -> '"mother" said hi'
'My father-in-law called.' -> 'My papa -in-law called.'
'e-mail your brother' -> 'e -mail your bro'
"a 'quoted' word" -> "a'quoted' word"

Expected behavior

Words are swapped wherever they appear and surrounding punctuation is left as written: Ask (papa) first., "mama" said hi, My papa-in-law called., e-mail your bro, a 'quoted' word. The existing whitespace normalization (test_awkward_spacing) stays as it is.

Version

main at 60c3386a, Python 3.11, Windows.

主要语言
Python
星标
4.6k
派生
944
平均合并
2 天 20 小时
30 天内合并 PR
309

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/PyRIT 的其他 Issue

查看 microsoft/PyRIT 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。