namedex package

Submodules

namedex.namedex module

An implementation of the soundex algorithm as mentioned in https://www.wikiwand.com/en/Soundex.

namedex.namedex.command_line()[source]

Run namedex in the commandline

This function runs when the module is ran as a script. It only prints the results, it does not output to stout.

namedex.namedex.convert_to_number(name)[source]

Replaces letters to corresponding numbers to build the soundex.

Parameters:name (list) – The letters of the name split into a list.
Returns:The corresponding numbers for the consonants.
Return type:list
namedex.namedex.create_soundex(entered_name)[source]

Creates the soundex for the given name and returns it.

Parameters:entered_name (str) – The name to be converted into a soundex.
Returns:A soundex.
Return type:str
namedex.namedex.make_into_list(name)[source]

Lower cases the name and converts it into a list.

Takes the string passed in and lowercase it. Then it converts it to a list.

Parameters:name (str) – A name as a string.
Returns:The name all lower cased and made into a list.
Return type:list
namedex.namedex.remove_adjacent_letters(name)[source]

Removes digits that repeats.

Removes duplicate digits that are adjacent to each other with a few exceptions.

Duplicate digit that are adjacent are removed. If duplicate digits are separated by a ‘w’ or ‘h’ then remove one of the digits. If duplicate digits are separated by a ‘w’ or ‘h’ then remove one of the digits. If duplicate digits are separated by a ‘w’ or ‘h’ then remove one of the digits. If duplicate digits are separated by a vowel then leave the duplicate numbers.

>>> remove_adjacent_letters(['4', '2', '2'])
['4', '2']
>>> remove_adjacent_letters(['4', '2', 'h', '2'])
['4', 'h', '2']
>>> remove_adjacent_letters(['4', '2', 'a', '2'])
['4', '2', 'a', '2']
Parameters:name (list) – A list of soudex numbers and vowels including ‘w’ and ‘h’.
Returns:Soundex numbers with duplicated numbers removed.
Return type:list
namedex.namedex.remove_dropped_letters(name)[source]

Remove the vowels, ‘y’, ‘h’, and ‘w’ from name.

Removes all vowels and the the letters ‘y’, ‘h’, and ‘w’ from _name_.

Parameters:name (list) – The name to be processed.
Returns:name without vowels, ‘y’, ‘h’, or ‘w’ letters.
Return type:list
namedex.namedex.remove_first_number(name)[source]

Removes the first digit from list

The first digit has to be removed at this point as required by the soundex algorithm.

Parameters:name (list) – The name list
Returns:The name list with the first digit removed.
Return type:list
namedex.namedex.strip_and_pad(name)[source]

Makes the list 3 digits long.

If the _name_ list is passed in with more than three digits then only the first three digits are kept. If the _name_ list is shorter than three digits then the _name_ list is padded with ‘0’ until it is three digits long.

Parameters:name – The name list
Returns:A list that is only 3 digits long.

Module contents

Top-level package for Namedex.