Repository navigation
FEAT: Add PigLatinConverter (pig_latin converter) - #4447
Roman Lutz (romanlutz) wants to merge 3 commits into
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The converter mishandles tab- and newline-delimited words and uses a quadratic-time regex that can block the event loop on punctuation-heavy input.
2 open issues
What changed in this PR
Adds Pig Latin prompt encoding to PyRIT’s converter collection and makes it available in the garak Encoding scenario.
Changes:
- Implements
PigLatinConverterwith configurable vowel suffixes, word selection, and punctuation/case handling. - Exports the converter and registers
pig_latinas anALL-only encoding technique. - Adds conversion tests, identifier samples, and a Python documentation example.
| File | Description |
|---|---|
tests/unit/scenario/garak/test_encoding.py |
Updates technique counts and ALL-only expectations. |
tests/unit/registry/converter_identifier_samples.py |
Adds vowel-suffix samples for identifier checks. |
tests/unit/converter/test_pig_latin_converter.py |
Tests conversion rules, formatting, and input validation. |
pyrit/scenario/scenarios/garak/encoding.py |
Registers the Pig Latin technique and converter variant. |
pyrit/converter/pig_latin_converter.py |
Implements the word-level Pig Latin converter. |
pyrit/converter/__init__.py |
Adds lazy export and typing support. |
doc/code/converters/1_text_to_text_converters.py |
Adds a Pig Latin usage example. |
Review effort: Balanced
| # (from the first letter to the last letter, interior punctuation included), and | ||
| # trailing non-letters. Leading/trailing punctuation is preserved verbatim so that | ||
| # marks like ``"`` ``(`` ``)`` ``.`` ``,`` stay where they were. | ||
| _TOKEN_PATTERN = re.compile(r"^([^A-Za-z]*)(.*?)([^A-Za-z]*)$") |
| Raises: | ||
| ValueError: If ``vowel_initial_suffix`` is not one of the supported values. | ||
| """ | ||
| super().__init__(word_selection_strategy=word_selection_strategy) |
| print("ROT13:", await ROT13Converter().convert_async(prompt=prompt)) # type: ignore | ||
| print("Base64:", await Base64Converter().convert_async(prompt=prompt)) # type: ignore | ||
| print("Base2048:", await Base2048Converter().convert_async(prompt=prompt)) # type: ignore | ||
| print("Pig Latin:", await PigLatinConverter().convert_async(prompt=prompt)) # type: ignore |
There was a problem hiding this comment.
[P2] Synchronize the published converter notebooks
Update the paired 1_text_to_text_converters.ipynb with this import, example, and saved output. The documentation builds the committed notebooks without executing the percent-format source, so readers do not see the Pig Latin example added here. Also refresh 0_converters.ipynb's generated modality table, which omits PigLatinConverter; the existing table code already discovers the converter.

Adds this converter as part of the gap-1 converter series (splitting the esoteric cipher / encoder set into per-converter and per-base PRs). Includes a unit test and garak Encoding-scenario registration; CI-validated locally.
Sibling PRs will be cross-linked once the series is open.
🤖 Generated with Claude Code
gap-1 converter series — splitting the esoteric cipher / encoder set into reviewable PRs (open each independently; they touch the same four registration files, so later ones rebase as earlier ones merge):