BUG ColloquialWordswapConverter skips words next to punctuation and inserts spaces into hyphenated words
维护者通常 2 天内回复
评估
调研方向
在 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-mailbecomese -mail,father-in-lawbecomespapa -in-law. - The clean-up regex removes a space the user wrote:
a 'quoted' wordbecomesa'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
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/PyRIT 的其他 Issue
-
BUG UnicodeReplacementConverter writes characters outside the BMP as invalid five-digit \u escapes可能已有人在做 @ShivamSharma43 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
microsoft/PyRIT#3095 · 3 条评论 ·
维护者通常 2 天内回复
-
BUG Configuration keeps runtime-status errors after polling recovers可能已有人在做 @joeyvictorino 于 2 天前认领。 未关闭Bug: triage GUI help wanted
难度 2/5 1-3 小时 新手友好度 86/100
microsoft/PyRIT#2868 · 4 条评论 · 已指派 1 人 ·
维护者通常 2 天内回复
-
BUG: MemoryInterface.get_request_from_response fails with IndexError for non-zero starting sequence or sequence gaps可能已有人在做 @RohithPariki 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 25/100
维护者通常 2 天内回复
-
Conversation editor never revokes blob URLs of removed attachments可能已有人在做 @ManoharPaturi 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 25/100
维护者通常 2 天内回复
相似的 Issue
-
难度 1/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 85/100
tharje/spooler-v2#20 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
Bump version of azure-servicebus可能已有人在做 @joostlek 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
home-assistant/core#186275 ·
维护者通常 1 天内回复
-
documentation
难度 1/5 1 小时以内 新手友好度 72/100