namebot.strainer module

Provides filtering functions for reducing large sets of generated words.

Recommended usage: filtered results using a list comprehension of all filters ‘anded’ together. e.g:

>>> filtered = [word for word in words if
            filter_length(word, max_length=7) and
            filter_startswith(word, beginning='c') and
            filter_startswith(word, beginning='c') and
            filter_endswith(word, ending='e') ...]
namebot.strainer.filter_consonant_ending(word)[source]

Filter words that end in consonants.

Parameters:(str) (word) – The word to filter.
Rtype match (bool):
 An re.MatchObject or None.
namebot.strainer.filter_dmetaphone(word, code=None)[source]

Get double metaphone value, checking score.

Where second key being None, an easy pronunciation is unlikely.

Parameters:
  • (str) (word) – The word.
  • (str, optional) (code) – The double metaphone pronunciation code.
Rtype bool:

The resulting check.

namebot.strainer.filter_endswith(word, ending=None)[source]

Filter words ending with a specified suffix.

Parameters:
  • (str) (word) – A word.
  • (str, optional) (ending) – The optional ending to check.
Rtype bool:

The resulting check.

namebot.strainer.filter_length(word, min_length=4, max_length=13)[source]

Filter based on min and max lengths.

Parameters:
  • (str) (word) – The word.
  • (int, optional) (max_length) – The minimum allowed length.
  • (int, optional) – The maximum allowed length.
Return type:

bool: The resulting check.

namebot.strainer.filter_nysiis(word, code=None)[source]

Get nysiis value, checking score.

Parameters:
  • (str) (word) – The word.
  • (str, optional) (code) – The nysiis pronunciation code.
Rtype bool:

The resulting check.

namebot.strainer.filter_soundex(word, code=None)[source]

Get soundex value, checking result against a given code.

Parameters:
  • (str) (word) – The word.
  • (str, optional) (code) – The soundex pronunciation code.
Rtype bool:

The resulting check.

namebot.strainer.filter_startswith(word, beginning=None)[source]

Filter a word starting with specified string.

Parameters:
  • (str) (word) – The word.
  • (str, optional) (beginning) – The beginning string to check.
Return type:

bool: The resulting check.

namebot.strainer.filter_tld(word, tld='.com')[source]

Check if a word ends with a TLD suffix (can be used to make a valid TLD).

Parameters:
  • (str) (word) – The wor.d
  • (str, optional) (tld) – The TLD to check against, with or without a dot.
Rtype bool:

The resulting check.

namebot.strainer.filter_vowel_cons_ratio(word, ratio=0.5)[source]

Return True if the ratio of vowels to consonants is > ratio.

This can be used as an ad-hoc pronunciation filter.

Parameters:
  • (str) (word) – The word
  • (float, optional) (ratio) – The ratio
Return type:

int

namebot.strainer.filter_vowel_ending(word)[source]

Filter words that end in vowels.

Parameters:(str) (word) – The word to filter.
Rtype match (bool):
 A re.MatchObject or None.