Skip to content

FEAT: Add PigLatinConverter (pig_latin converter) - #4447

Open
Roman Lutz (romanlutz) wants to merge 3 commits into
microsoft:mainfrom
romanlutz:gap1-piglatin
Open

Roman Lutz (romanlutz) wants to merge 3 commits into
microsoft:mainfrom
romanlutz:gap1-piglatin

Conversation

@romanlutz

@romanlutz Roman Lutz (romanlutz) commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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):

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 23:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 PigLatinConverter with configurable vowel suffixes, word selection, and punctuation/case handling.
  • Exports the converter and registers pig_latin as an ALL-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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants