Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Chiusa Adatta ai principianti
#3,131 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@ShivamSharma43 ci sta già lavorando.

Dal 11/10/2026.

  • #3133 di @ShivamSharma43 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Individua ColloquialWordswapConverter nel pacchetto dei converter di PyRIT e leggi la relativa logica di tokenizzazione e spaziatura, insieme al test esistente test_awkward_spacing. Riproduci gli esempi nell’issue e controlla i test dei converter vicini per verificare gli scambi di parole previsti. Il lavoro è completato quando la punteggiatura e le parole con trattino mantengono la spaziatura originale, mentre le parole idonee vengono scambiate, e la normalizzazione degli spazi esistente continua a passare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
4.6k
Fork
944
Merge medio
2g 20h
PR unite (30g)
309

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/PyRIT

Tutte le issue di microsoft/PyRIT

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.