Skip to main content

A Python package to convert text to Pig Latin - built from source for Chainguard

Project description

Chainguard Pig Latin

A Python package for converting English text to Pig Latin. Built from source to ensure security and transparency.

What is Pig Latin?

Pig Latin is a language game where words are altered according to simple rules:

  • Words starting with consonants: Move the consonant(s) to the end and add "ay" (e.g., "hello" → "ellohay")
  • Words starting with vowels: Add "way" to the end (e.g., "apple" → "appleway")

Features

  • 🔒 Secure: Built from source using Chainguard's secure supply chain
  • 🎯 Accurate: Properly handles consonant clusters, including "qu" combinations
  • 📝 Smart: Preserves capitalization, punctuation, and whitespace
  • 🚀 Fast: Efficient pure Python implementation
  • 🛠️ CLI & Library: Use as a command-line tool or import into your code
  • Well-tested: Comprehensive test suite with high coverage
  • 📦 Type-safe: Includes type hints for better IDE support

Installation

Install from PyPI:

pip install chainguard-pig-latin

Usage

As a Library

from chainguard_pig_latin import to_pig_latin, word_to_pig_latin

# Convert a single word
word_to_pig_latin("hello")
# Output: "ellohay"

word_to_pig_latin("apple")
# Output: "appleway"

# Convert a sentence
to_pig_latin("Hello world!")
# Output: "Ellohay orldway!"

to_pig_latin("The quick brown fox jumps over the lazy dog")
# Output: "Ethay uickqay ownbray oxfay umpsjay overway ethay azylay ogday"

# Capitalization is preserved
to_pig_latin("Python is AWESOME!")
# Output: "Ythonpay isway AWESOMEWAY!"

As a Command-Line Tool

Convert text directly from the command line:

# Convert text from arguments
pig-latin hello world
# Output: ellohay orldway

pig-latin "The quick brown fox"
# Output: Ethay uickqay ownbray oxfay

# Read from stdin
echo "Hello world" | pig-latin
# Output: Ellohay orldway

# Convert multiple lines
cat myfile.txt | pig-latin

Examples

Consonant Words

word_to_pig_latin("hello")   # "ellohay"
word_to_pig_latin("world")   # "orldway"
word_to_pig_latin("string")  # "ingstray"
word_to_pig_latin("glove")   # "oveglay"

Vowel Words

word_to_pig_latin("apple")     # "appleway"
word_to_pig_latin("elephant")  # "elephantway"
word_to_pig_latin("igloo")     # "iglooway"
word_to_pig_latin("octopus")   # "octopusway"

Consonant Clusters

word_to_pig_latin("three")    # "eethray"
word_to_pig_latin("school")   # "oolschay"
word_to_pig_latin("stretch")  # "etchstray"

Special "qu" Handling

word_to_pig_latin("queen")   # "eenquay"
word_to_pig_latin("quick")   # "ickquay"
word_to_pig_latin("square")  # "aresquay"

Capitalization and Punctuation

word_to_pig_latin("Hello")    # "Ellohay"
word_to_pig_latin("HELLO")    # "ELLOHAY"
word_to_pig_latin("hello!")   # "ellohay!"
word_to_pig_latin("(hello)")  # "(ellohay)"

Development

Setup

Clone the repository and install development dependencies:

git clone https://github.com/alamorre/chainguard-pig-latin.git
cd chainguard-pig-latin
pip install -e .
pip install pytest

Running Tests

Run the test suite:

pytest tests/ -v

Run tests with coverage:

pytest tests/ --cov=chainguard_pig_latin --cov-report=term-missing

Building from Source

Build the package:

pip install build
python -m build

This creates distribution files in the dist/ directory.

Installing Locally

Install the package in development mode:

pip install -e .

API Reference

word_to_pig_latin(word: str) -> str

Convert a single word to Pig Latin.

Parameters:

  • word (str): A single word to convert

Returns:

  • str: The word converted to Pig Latin

Example:

word_to_pig_latin("hello")  # "ellohay"

to_pig_latin(text: str) -> str

Convert a string of text to Pig Latin.

Parameters:

  • text (str): The text to convert to Pig Latin

Returns:

  • str: The text converted to Pig Latin

Example:

to_pig_latin("Hello world!")  # "Ellohay orldway!"

Pig Latin Rules Implemented

  1. Consonant Start: Words beginning with consonant sounds have the consonant(s) moved to the end, followed by "ay"

    • Simple: "pig" → "igpay"
    • Clusters: "string" → "ingstray"
    • Special: "queen" → "eenquay" (qu stays together)
  2. Vowel Start: Words beginning with vowel sounds have "way" added to the end

    • "apple" → "appleway"
    • "eat" → "eatway"
  3. Preservation:

    • Capitalization is maintained
    • Punctuation is preserved
    • Whitespace is kept intact

Why Chainguard?

This package is built using Chainguard's secure software supply chain practices:

  • ✅ Built from source, not from pre-built binaries
  • ✅ Transparent build process
  • ✅ Minimal dependencies
  • ✅ Regular security updates
  • ✅ Full provenance and SBOM (Software Bill of Materials)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Add tests for your changes
  4. Ensure all tests pass (pytest)
  5. Commit your changes (git commit -m 'Add some amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

Changelog

Version 0.1.0 (Initial Release)

  • Basic Pig Latin conversion for words and text
  • Command-line interface
  • Consonant cluster handling
  • Special "qu" combination support
  • Capitalization and punctuation preservation
  • Comprehensive test suite

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chainguard_pig_latin-0.1.1.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chainguard_pig_latin-0.1.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file chainguard_pig_latin-0.1.1.tar.gz.

File metadata

  • Download URL: chainguard_pig_latin-0.1.1.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for chainguard_pig_latin-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a2a86be10e3d8761763cb00f002f5a8a9a30ef215aab3853e419ce226ca0c065
MD5 98fede742c80d0cc23ad646562ac0a37
BLAKE2b-256 5117f2fd99cd9939d144f529d100db2da1d7be6e23a9749b9d7fab903ecd8a65

See more details on using hashes here.

File details

Details for the file chainguard_pig_latin-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for chainguard_pig_latin-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e604a23bb9da5c2444de4c8f4ff962b96bfc8f6fe4d6993de04262e9a0489805
MD5 45ac2c2673b13b3ffe350e9d16b24de2
BLAKE2b-256 7badf3b6537a9af7744a251737f5933405d27edcbeac224bf204362ef71c8f98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page