opensextant.advas_phonetics
index
./python/opensextant/advas_phonetics.py

# -*- coding: utf-8 -*-
# ----------------------------------------------------------
# AdvaS Advanced Search 
# module for phonetic algorithms
#
# (C) 2002 - 2005 Frank Hofmann, Chemnitz, Germany
# email fh@efho.de
# ----------------------------------------------------------
#
# changed 2005-01-24
# 2012-01-01 MU adapted to support various Unicode transliterations in Metaphone
# 2021-03-25 MU migrated to Xponents here

 
Modules
       
re

 
Functions
       
caverphone(term)
returns the language key using the caverphone algorithm 2.0
metaphone(text)
returns metaphone code for a given string
nysiis(term)
returns New York State Identification and Intelligence Algorithm (NYSIIS) code for the given term
soundex(term)
Return the soundex value to a string argument.

 
Data
        EMPTY_STRING = ''
metaphone_std_trans = {'b': 'b', 'c': 'k', 'd': 't', 'g': 'k', 'h': 'h', 'k': 'k', 'n': 'n', 'p': 'p', 'q': 'k', 's': 's', ...}
metaphone_table = {'ae': 'e', 'gn': 'n', 'pn': 'n', 'wh': 'w', 'wr': 'n'}
re_CI = re.compile('c[iey]')
re_DG = re.compile('dg[eyi]')
re_GHvowel = re.compile('gh[aeiouy]')
re_SCI = re.compile('sc[iey]')
re_SIvowel = re.compile('si[ao]')
re_TIvowel = re.compile('ti[ao]')
re_shadowedW = re.compile('w[^aeiouy]')
re_softH = re.compile('[csptg]h')
re_sub_nonalpha = re.compile('[^a-zḑḩñşţz̧]')
re_sub_vowels = re.compile('[aeiou]')
re_vowelHvowel = re.compile('[aeiouyāīū][hḩ][^aeiouy]')
vowels = {'a', 'e', 'i', 'o', 'u'}