def _select_generator(self, slide_nr, total_slides, prohibited_generators):
     """Select a generator for a certain slide number"""
     logging.debug(
         'presentation_schema._select_generator self._slide_generators: {}'.
         format(self._slide_generators))
     logging.debug('self._ignore_weights: {}'.format(self._ignore_weights))
     if self._ignore_weights:
         return random_util.choice_optional(self._slide_generators)
     _selected_generator = random_util.weighted_random(
         self._get_weighted_generators_for_slide_nr(slide_nr, total_slides,
                                                    prohibited_generators))
     logging.debug('_selected_generator: {}'.format(_selected_generator))
     return _selected_generator
def random_word():
    return choice_optional(WORDS)
 def __call__(self, argument):
     weighted_list = self._weighted_list_creator(argument)
     if weighted_list:
         return random_util.choice_optional(
             [element[1] for element in weighted_list])
 def __call__(self, presentation_context):
     return random_util.choice_optional(
         self._list_generator(presentation_context))
from talkgenerator.util import generator_util, language_util, random_util, os_util
from talkgenerator.sources import wikihow, conceptnet

known_functions = {
    "title": str.title,
    "lower": str.lower,
    "upper": str.upper,
    "dashes": lambda words: words.replace(" ", "-"),
    "first_letter": lambda words: words[0],
    "a": lambda word: language_util.add_article(word),
    "ing": language_util.to_present_participle,
    "plural": language_util.to_plural,
    "singular": language_util.to_singular,
    "synonym": generator_util.FromListGenerator(language_util.get_synonyms),
    "2_to_1_pronouns": language_util.second_to_first_pronouns,
    "wikihow_action": lambda seed: random_util.choice_optional(wikihow.get_related_wikihow_actions(seed)),
    "get_last_noun_and_article": language_util.get_last_noun_and_article,

    # Conceptnet
    "conceptnet_location": conceptnet.weighted_location_generator,

    # Checkers
    "is_noun": lambda word: word if language_util.is_noun(word) else None,
    "is_verb": lambda word: word if language_util.is_verb(word) else None,
}


class AbstractTextGenerator(object):
    def generate(self, variables_dictionary):
        raise NotImplementedError()