Skip to main content

General-purpose phonetic similarity detection — homophones, near-homophones, and sound-alike analysis

Project description

phonemenal logo

phonemenal

Phonetic similarity and homophone detection library for Python — near-homophones, sound-alike collisions, and variant generation.

Docs PyPI Python License


Features

  • Three scoring algorithms (all normalized 0.0–1.0):
    • PPC-A — Positional Phoneme Correlation (Absolute)
    • PLD — Phoneme Levenshtein Distance at syllable level
    • LCS — Longest Common Subsequence ratio on phoneme sequences
  • Composite scoring with configurable weights
  • Exact homophone discovery via CMU Pronouncing Dictionary inversion
  • Near-homophone search with threshold-based fuzzy matching
  • Variant generation — phonetic substitutions, morphological variants, and separator permutations
  • Compound word splitting with homophone permutation recombination
  • Fast fallback encoder for words not in the dictionary (brand names, neologisms)
  • Batch collision scanning — forward and reverse scanning pipelines
  • LLM-powered deep analysis (optional, via Anthropic/OpenAI API or local agents)
  • Rich CLI with formatted tables and JSON output

Install

pip install phonemenal

# With LLM support
pip install phonemenal[llm]

Quick Start

from phonemenal import similarity, homophones, variants, splitting, fallback, scanning

# Compare two words (all scores 0.0–1.0)
similarity.ppc("crowd", "crown")        # PPC-A
similarity.pld("elastic", "fantastic")   # PLD
similarity.lcs("packaging", "packages")  # LCS
similarity.composite("crowd", "crown")   # Weighted average

# Find exact homophones
homophones.find("blue")  # → ["blew"]

# Find near-homophones
homophones.find_similar("crowd", min_score=0.7)

# Generate sound-alike variants
variants.generate("flask")  # → {"phlask", "flazk", ...}
variants.generate_morphological("packaging")  # → {"packaged", "packager", ...}

# Split compound words & generate permutations
splitting.split("bluevoyage")  # → ["blue", "voyage"]
splitting.homophone_permutations("bluevoyage")  # → all recombinations

# Fallback for non-dictionary words
fallback.phonetic_key("numpy")   # → "nAmpY"
fallback.phonetic_key("numpie")  # → "nAmpY" (same key)

# Batch collision scanning
matches = scanning.scan(
    candidates=["numpie", "phlask"],
    known_names=["numpy", "flask"],
)

CLI

phonemenal similarity crowd crown           # compare with all algorithms
phonemenal similarity crowd crown -a ppc    # specific algorithm
phonemenal homophones blue                  # exact homophones
phonemenal variants flask -m                # phonetic + morphological variants
phonemenal split bluevoyage -p              # split & show permutations
phonemenal compare crowd crown              # full comparison report
phonemenal compare crowd crown -j           # JSON output
phonemenal analyze numpy --provider anthropic  # LLM deep analysis
phonemenal prompt numpy | pbcopy            # get raw prompt

Algorithms

PPC-A (Positional Phoneme Correlation — Absolute)

Builds positional phoneme combinations by traversing forward and reverse directions with padding, then measures set intersection. Captures how much of the positional phoneme structure two words share.

PLD (Phoneme Levenshtein Distance)

Syllable-level edit distance using the CMU dict's stress markers to split phonemes into syllable groups. Each syllable is an atomic unit, so the distance reflects how many whole syllables differ — matching how sound flows in speech.

LCS (Longest Common Subsequence)

Ratio of the longest common subsequence length to the total sequence length. Applied to phoneme sequences from CMU dict, or to raw character strings as a fallback.

Composite

Weighted average of all three algorithms, configurable per call. Default: equal weights. All bounded 0.0–1.0.

Fallback Encoder

Simplified Metaphone-inspired encoding for words not in the CMU dict. Applies digraph replacement, vowel normalization, and character collapsing to produce phonetic keys. Sound-alike names produce the same or similar keys — e.g. numpy and numpie both map to nAmpY.

Documentation

Full documentation is available at brokensound77.github.io/phonemenal.

License

Apache-2.0

Background and Research

This project stems from previous research on homophonic collisions conducted by Reagan Short and Justin Ibarra. You can check out our TROOPERS 2023 talk: Homophonic Collisions: Hold me closer Tony Danza for more background on the problem space and their approach to phonetic similarity detection.

Coils of Communication Chaos

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

phonemenal-0.1.1.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

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

phonemenal-0.1.1-py3-none-any.whl (28.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: phonemenal-0.1.1.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for phonemenal-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ff64750866fa8d2a6456de632ec404286a63267a7667de2e4a64d1c35eb4370e
MD5 90b7db14bdf793a0c7eb6bf3afcd4690
BLAKE2b-256 d7e28f101ea94edc7c5182e2ddf40a0ef90ce2eb37b2ec9d835558c644422ecf

See more details on using hashes here.

Provenance

The following attestation bundles were made for phonemenal-0.1.1.tar.gz:

Publisher: publish.yml on brokensound77/phonemenal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: phonemenal-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 28.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for phonemenal-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9c735e2a35e669489e77bf4969851065c2e1fee5683f5e077a2e093a48a41837
MD5 d6a44bb7829ad66a280c7ec67a7712a3
BLAKE2b-256 0740d75bf2787f7133bbb9d2863684dc6a385cb63a4174029a7c2e1a5001a966

See more details on using hashes here.

Provenance

The following attestation bundles were made for phonemenal-0.1.1-py3-none-any.whl:

Publisher: publish.yml on brokensound77/phonemenal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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