Skip to content

Text doublemetaphonecode

github-actions[bot] edited this page Sep 21, 2026 · 30 revisions

Development build. This page describes main, not a released package. The latest published Lodestar.Text is 0.6.0 — read its documentation.

HomeTextPhonetic encoding

DoubleMetaphoneCode

A word's two Double Metaphone codes.

public readonly record struct DoubleMetaphoneCode

Example — the two codes, and what an empty alternate means.

using Lodestar.Text.Phonetics;

DoubleMetaphoneCode smyth = DoubleMetaphone.Encode("Smyth");
string primary = smyth.Primary;  // => SM0
string secondary = smyth.Secondary;  // => XMT

DoubleMetaphoneCode wright = DoubleMetaphone.Encode("Wright");
string one = wright.Primary;  // => RT
string alternate = wright.Secondary;  // =>

RemarksSecondary is empty when the word has one reading, which is most words. The reference repeats the primary there; empty is the convention jellyfish, metaphone and phonetics share, and decision 0005 takes it for this API so that "has an alternate" is a property a caller can test rather than a comparison it has to make.

Being a record struct, two codes compare equal by value, which makes the pair usable as a dictionary key when grouping a corpus by sound. That is not the same as a phonetic match: equality here is both codes agreeing, while two words are candidates when any of their codes agree.

Applies to — net10.0, netstandard2.0.

See alsoDoubleMetaphone.Encode, DoubleMetaphone, the phonetics index.

Clone this wiki locally