Skip to main content

A Python package for encoding and decoding Morse code.

Project description

CI / CD

morseify

morseify is a lightweight Python package that brings the world of Morse code to anyone curious about how digital communication began. It offers intuitive encode and decode functionality to translate between English text and Morse code, along with built-in tools for text normalization and message validation.

For a more interactive experience, morseify also includes a quiz mode that generates random Morse code challenges for users to decode, making it both an educational and entertaining way to explore the fundamentals of encoded communication.

Features

  • Encode English text to Morse code
  • Decode Morse code to English text
  • Normalize text and Morse sequences
  • Validate Morse message formats
  • Explain Morse code with detailed breakdowns
  • Quiz mode to test Morse knowledge

Team Members

Installation / Setup

Install from PyPI:

pip install morseify-lumen

Or install from source:

git clone https://github.com/swe-students-fall2025/3-python-package-team_lumen.git
cd 3-python-package-team_lumen
pipenv install --dev

Activate the environment:

pipenv shell

Using morseify in Your Code

You can import and use morseify. Here's documentation for all available functions:

Core Functions

from morseify import encode, decode, is_valid

text = "HELLO WORLD"
morse = encode(text)
print(morse)

decoded = decode(morse)
print(decoded)

print(is_valid(morse))

Normalization Functions

from morseify.normalize import normalize_text, normalize_code

# Clean up raw text before encoding
text = "  Hello,  World!! "
cleaned = normalize_text(text)
print(cleaned)  # "HELLO, WORLD"

# Normalize Morse code before decoding
code = "....   . / /   .-.."
normalized = normalize_code(code)
print(normalized)  # ".... . / .-.."

Explain Function

from morseify.explain import explain

morse_message = ".... . .-.. .-.. ---"
output = explain(morse_message)
print(output)

Example output:

MORSE CODE BREAKDOWN
Input: .... . .-.. .-.. ---
Normalized: .... . .-.. .-.. ---

Step-by-step translation:
  ....      H
  .         E
  .-..      L
  .-..      L
  ---      → O

Final Message: HELLO

Quiz Function

from morseify.quiz import quiz

# Option 1: Let user choose mode interactively
quiz()

# Option 2: Specify the mode directly
quiz("reading")   # Decode morse → text
quiz("writing")   # Encode text → morse

Example terminal session:

MORSE CODE QUIZ
Choose your mode:
'reading'  - Decode morse code  text
'writing'  - Encode text  morse code

Enter the mode ('reading' or 'writing'): reading

READING MODE: Decode morse code  text

Morse code: .... . .-.. .-.. --- / .-- --- .-. .-.. -..

Your answer: HELLO WORLD

Correct! Well done!

Example Program

See our complete example program that demonstrates all functions:

from morseify.core import encode, decode, is_valid
from morseify.normalize import normalize_text, normalize_code
from morseify.explain import explain
from morseify.quiz import quiz


def main():
    print("=== MORSEIFY DEMO ===\n")

    # 1. Normalize text
    text = "  Hello,  World!! "
    normalized_text = normalize_text(text)
    print("Normalized text:", normalized_text)
    # Output: HELLO, WORLD

    # 2. Encode text to Morse code
    encoded = encode(normalized_text)
    print("\nEncoded Morse code:", encoded)
    # Output: .... . .-.. .-.. --- --..-- / .-- --- .-. .-.. -..

    # 3. Decode Morse code back to text
    decoded = decode(encoded)
    print("\nDecoded text:", decoded)
    # Output: HELLO, WORLD

    # 4. Validate a Morse code string
    print("\nIs valid Morse code?", is_valid(encoded))
    # Output: True

    # 5. Explain Morse code step-by-step
    print("\nMorse code breakdown:\n")
    explanation = explain(encoded)
    print(explanation)

    # 6. Start an interactive quiz session
    print("\n=== STARTING QUIZ ===")
    print("You can practice encoding or decoding Morse messages.\n")
    quiz()  # Interactive: user selects 'reading' or 'writing'


if __name__ == "__main__":
    main()

Project Structure

morseify/                 
    ├── __init__.py           # Package initializer
    ├── __main__.py           # Entry point for CLI
    ├── cli.py                # Command-line interface logic
    ├── core.py               # Encode, decode, and validation functions
    ├── explain.py            # Step-by-step morse code explanation logic
    ├── mapping.py            # Dictionary mapping letters  morse code
    ├── normalize.py          # Text and morse normalization utilities
    └── quiz.py               # Interactive quiz feature
tests/                        # Unit tests for all functions above
    ├── test_decode.py
    ├── test_encode.py
    ├── test_explain.py
    ├── test_is_valid.py
    ├── test_normalize_code.py
    ├── test_normalize_text.py
    └── test_quiz.py

Contributing to Morseify

We welcome contributions that improve functionality, testing, or documentation. Before contributing, make sure your environment is set up correctly and that all tests pass.

Development Workflow

Create a new branch for your feature:

git checkout -b feature/<feature-name>
git add .
git commit -m "Add <feature-description>"
git push origin feature/<feature-name>

Then open a Pull Request on GitHub to the piefile-experiment branch.

Running Tests

Follow Installation / Setup instructions first, then run the following commands:

# Run all tests
pipenv run pytest -v

# Run tests with coverage report
pytest tests/ --cov=morseify --cov-report=term-missing

# Run a specific test file
pytest tests/test_explain.py -v

All pull requests are automatically tested using GitHub Actions. Make sure tests pass locally before submitting your PR.

PyPI Package

This package is available on PyPI: morseify-lumen.

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

morseify_lumen-0.1.2.tar.gz (53.4 kB view details)

Uploaded Source

Built Distribution

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

morseify_lumen-0.1.2-py3-none-any.whl (36.3 kB view details)

Uploaded Python 3

File details

Details for the file morseify_lumen-0.1.2.tar.gz.

File metadata

  • Download URL: morseify_lumen-0.1.2.tar.gz
  • Upload date:
  • Size: 53.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for morseify_lumen-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4c27f6203622b46457214533db9f278e544414042598fce4ecc0a744f804480b
MD5 907453cb72bf438f69920fdd836e807c
BLAKE2b-256 61a3aec4119e35dc87f5591c7889d63915da2db59a60e668d5690f7aac81730e

See more details on using hashes here.

File details

Details for the file morseify_lumen-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: morseify_lumen-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 36.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for morseify_lumen-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 22e005c1a81dd92d0d2235f3b7dd7df0093fe364fdccdd5de1ed543d0d04217d
MD5 4dad189bf9479caa1907d06f955fd9d9
BLAKE2b-256 5f47ae889c328e05fec42846d73c8a2a9f2330ed17f2d321e0bef6e2648e1a78

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