Module dictionary
This module allows you to manage input and output files and process the dictionary.
Functions
def find_separator(alphabet)
-
find_separator()
gets the first char in the list above that is not in the alphabet, if no such character exists, an exception is raised.- alphabet (list): the used alphabet (from input file or from dictionary)
- return (char): the first separator that is not in the alphabet
def get_alphabet_from_dict(dictionary, add_separator=True)
-
get_alphabet_from_dict()
gets the alphabet from the dictionary by adding each used letter.- dictionary (list): the input dictionary (before processing)
- return (list): the alphabet based on the letters used in the dictionary
def get_length_range(dictionary, percent)
-
get_length_range()
gets the minimum and maximum size values for which a percentage of words in dictionary lie between them.- dictionary (list): the input dictionary (while processing)
- percent (int): the percentage of words within the interval
- return (list): the minimum and maximum size values
def get_missing_letters(dictionary, alphabet)
-
get_missing_letters()
gets every word from the dictionary that uses at least one letter that is not in the alphabet.- dictionary (list): the input dictionary (while processing)
- alphabet (list): the used alphabet (from input file or from dictionary)
- return (list): the list of letters used at least once in the dictionary that are not in the alphabet
def lower_case_words(dictionary)
-
lower_case_words()
lower-cases every word from the dictionary.- dictionary (list): the input dictionary (while processing)
- return (list): the dictionary with each word lower-cased
def open_alphabet(filename, add_separator=True)
-
open_alphabet()
gets the input alphabet from a file.- filename (str): the name of the file to open (
read
mode) - return (list): the input alphabet
- filename (str): the name of the file to open (
def open_dictionaries(filenames)
-
open_dictionary()
gets the input dictionary from a file.- filenames (list): the list of names of files to open (
read
mode) - return (list): the input dictionary
- filenames (list): the list of names of files to open (
def print_acronyms(dictionary)
-
print_acronyms()
prints every acronyms from the dictionary. An acronyms is a word such asword == word.upper()
.- dictionary (list): the input dictionary (while processing)
- return (None)
def print_plural_words(dictionary, lang)
-
print_plural_words()
prints every word from the dictionary that is already in the dictionary in singular form.- dictionary (list): the input dictionary (while processing)
- lang (str): the language used to follow plural rules (only
FR
is available yet) - return (None)
def process_dictionary(dictionary)
-
process_dictionary()
sorts the dictionary and removes duplicated words.- dictionary (list): the input dictionary (while processing)
- return (list): the sorted dictionary without duplicated words
def process_size(size)
-
process_size()
converts the size argument to a min_len and max_len couple (tuple length two).- size (str): the input argument value
- return (couple): the minimum and maximum size values
def remove_acronyms(dictionary)
-
remove_acronyms()
removes every acronyms from the dictionary. An acronyms is a word such asword == word.upper()
.- dictionary (list): the input dictionary (while processing)
- return (list): the dictionary without acronyms
def remove_missing_letters(dictionary, missing_letters)
-
get_missing_letters()
removes from the dictionary every word that uses at least one letter that is not in the alphabet.- dictionary (list): the input dictionary (while processing)
- missing_letters (list): letters used in the dictionary that are not in the alphabet
- return (list): the dictionary without any word that contain one word from missing_letters
def remove_plural_words(dictionary, lang)
-
remove_plural_words()
removes from the dictionary every word that is already in the dictionary in singular form.- dictionary (list): the input dictionary (while processing)
- lang (str): the language used to follow plural rules (only
FR
is available yet) - return (list): the dictionary without duplicated words in singular / plural forms
def write_clean_dictionary(dictionary, filename)
-
write_clean_dictionary()
writes the processed dictionary in a file.- dictionary (list): the input dictionary (after processing)
- filename (str): the name of the file to open (
write
mode) - return (None)
def write_generated_words(word_list, filename)
-
write_generated_words()
writes the list of generated words in a file.- word_list (str): the string that contain all generated words
- filename (str): the name of the file to open (
write
mode) - return (None)