2

I am trying to come up with a way using Python to find phonetic similarities between how differently written names with different meanings in different languages might sound alike. Names can be multiple words, even just acronyms, but not full sentences. There can be numbers and special characters as well in the names. The ultimate goal is to have a database of names, and compare one new name with the ones in the database and see which ones are more similar.

So far I tried:

  • Creating phonemes of the word with Phonetisaurus G2P with using the models here. Also with Allosaurus. I think the error rate is a bit high, but the main problem is I am not sure about how to compare the generated IPA phonemes because common distance algorithms such as Levenshtein do not consider the similar phonetic features of the phonemes, it just considers if they are the same character or not. I tried finding a table to see the similarities of IPA characters to map the values myself, but the IPA characters used in different projects are never all the same.

  • Generating audio files of each name according to its language with TTS and then extracting the features of the audio with libraries such as Librosa or SpeechPy. I believe this approach has potential, however, I am not sure about which features of the audio I should extract to accurately compare the way the words are heard, and also with what kind of a formula to calculate the general similarity using these features. Just taking the average didn't feel very ensuring.

  • I am checking a library called LingPy at the moment, but I couldn't figure out if and how I can use the options in it for what I am trying to do.

Even though there are many academic papers about comparing phonetic similarity of languages in general and audio processing, I couldn't find something that directly applies to what I am trying to do.

I would appreciate any resource that you can share about this.

Many thanks!

2
  • Related question here. I'm looking for something similar myself, for use in a spell-checker, and for "averaging" different source words in a conlang.
    – dan04
    Commented Dec 13, 2021 at 23:04
  • Another related question that talks about “featural distance” between phonemes.
    – dan04
    Commented Dec 16, 2021 at 23:14

2 Answers 2

4

A disclaimer is required, that linguistic reality is different from what your spelling-to-IPA guide gives you, so you could spend forever in disputes over the phonetic outputs of Somali, Quechua, Norwegian and so on. If a phonetic property of a language is not recorded in its orthography, your output will be wrong relative to the reality of the language. If you are willing to just accept their text-to-IPA conversion, then you need a standard "number" for computing similarity, for example the relationship between [β] and [d] or [k] and [ɨ].

There is an easy way to compute that: convert IPA letters into SPE binary features (Sound Pattern of English). Thus, [β] is [+continuant,–sonorant,+voice,–nasal,+anterior,–coronal...] and [d] is [–continuant,–sonorant,+voice,–nasal,+anterior,+coronal...] (there is a two-feature difference). There is plenty of argument as to whether the SPE features are absolutely correct for the phonologies of all languages, but there is very little room for wiggle when it comes to relating transcriptional symbols to feature assignments. The features are standardized phonetic descriptions. However, they are un-weighted, so that the difference between [d] and [d̪] is equal to the difference between [d] and [t], but in reality, speakers of languages are likely to be able to better distinguish [d] and [n] as opposed to [d] and [d̪]. However, nobody has devised a universal weighting, because speakers are primarily attuned to distinguishing things actually in their language as opposed to abstractions from another language (so English speakers will perform poorly on a test distinguishing [d] and [d̪]).

1

I've been wanting to do something similar myself. I don't have an “ideal” solution yet, but feel free to use any of my ideas thus far.

Phoneme similarity function

You'll need to define some function f(x, y) that measures the “similarity” between phonemes x and y, as a real number between 0 and 1. It should have the properties:

  • A phoneme is perfectly similar to itself, i.e., f(x, x) = 1 for any phoneme x.
  • The operation is symmetric, i.e., f(x, y) = f(y, x) for any pair of phonemes.

One simple potential approach is to group the set of phonemes into “categories”, and then define f(x, y) as:

  • 1, if x = y
  • 0.5, if x ≠ y but x and y are in the same category.
  • 0, otherwise

For example, you can use the Soundex classification, but applied to phonemes instead of orthographic letters, resulting in the categories:

  • Category 0 (vowels, semivowels, and weak consonants) = aehijouwæɑɒɔəɛɜɪʊʌʔ
  • Category 1 (labial consonants) = bfpv
  • Category 2 (velars and sibilant consonants) = ksxzɡʃʒ
  • Category 3 (dental consonants) = dtðθ
  • Category 4 (lateral consonant) = l
  • Category 5 (nasals) = mnŋ
  • Category 6 (rhotic) = ɹ (+ rɾʀʁ for non-English words)

Some tweaks could be made to this system. For example:

  • Splitting the vowels into front/back or rounded/unrounded sub-categories.
  • Splitting the somewhat arbitrary Soundex category 2 into separate velar (kxɡ) and sibilant (szʃʒ) categories.
  • Merging categories 4 and 6 into a single "liquid consonant" category, for better compatibility with East Asian languages that don't have separate /l/ and /r/ sounds.
  • Having a non-zero similarity value for /v/ and /w/, which have been merged in many languages despite being in different Soundex categories.

It may be a good idea to have multiple layers of categorization (perhaps based on the SPE features mentioned in user6726's answer), and have the overall “similarity” of two phonemes be a weighted average of these.

I haven't come up with a particularly “elegant” way of building this similarity matrix, though. I'm open to suggestions.

Word similarity function

Once you have a phoneme_similarity function defined, you can use the following algorithm (in Python) to calculate the similarity between two words. I based it on the longest common subsequence problem, but modified it to handle fuzzy matching between characters.

def word_similarity(str1, str2):
    len1 = len(str1)
    len2 = len(str2)
    match_table = [[0] * (len2 + 1) for dummy in range(len1 + 1)]
    for i in range(1, len1 + 1):
        for j in range(1, len2 + 1):
            match_table[i][j] = max(
                match_table[i-1][j-1] + phoneme_similarity(str1[i-1], str2[j-1]),
                match_table[i-1][j],
                match_table[i][j-1]
            )
    return match_table[len1][len2] / (len1 + len2) * 2.0

Again, it may be more “accurate” to make some tweaks like:

  • Handling the words' consonant and vowel structures separately, and weighting one more than the other.
  • Handling swapped phonemes so that, e.g., ask and aks count as more than the 2/3 match calculated by the above code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.