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.2.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.2-py3-none-any.whl (28.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: phonemenal-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 33bbbd4632118fdf44a29a6da18537bef8d9d091189bbf0ff4586044963e752e
MD5 4fbbad350e5b5a547ac92695c7e4d3f4
BLAKE2b-256 8a804f689d0d945d9a461f7c0c4cdd2c82ca68f780d35179d4c12b09437832a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for phonemenal-0.1.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: phonemenal-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 28.7 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 064151bc48889fdfe2a21d87b7a19fcf762f0fb2663afea748d832945329fe5a
MD5 98594bb442951ae203b3cb26a96556f5
BLAKE2b-256 342a9f04c048c3553bd2a3d1c595e1c05f03b9fb2ff40261b88b35aaae02bef6

See more details on using hashes here.

Provenance

The following attestation bundles were made for phonemenal-0.1.2-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