""" Data Loaf usage example: Goldblum generator Generates alternate names by which you could address Jeff Goldblum, should you ever encounter him removing his shoes at an airport. See also: Idle Thumbs 43 """ from __future__ import print_function import dataloaf as loaf blum = loaf.choice( 'jeff gold blum game cold fold gate blast cast cool coat'.split() ) gold = loaf.transform(blum, lambda x: x.capitalize()) mc = loaf.weighted([ (1, 'Mc'), (9, ''), ]) goldblum = loaf.weighted([ (16, loaf.join('', [gold, ' ', mc, gold, blum])), (8, loaf.join('', [gold, blum, ' ', mc, gold, blum])), (1, loaf.join(' ', [gold] * 9)), ]) if __name__ == '__main__': print(goldblum.bake())
""" Data Loaf usage example: band names Generates names for indie bands that are destined to languish in obscurity. """ from __future__ import print_function import dataloaf as loaf noun = loaf.choice(( 'killer man vomit machine sofa zombie horse door beef anger fire water ' 'house summer lip hammock stick robot wheel' ).split()) cap_noun = loaf.transform(noun, lambda x: x.capitalize()) uncountable_noun = loaf.choice( 'Man Vomit Beef Anger Fire Water Summer'.split() ) adjective = loaf.choice(( 'Cold Electric Sea Giant Nuclear Flaming Old Battle Damp DJ Summer Proto' ).split()) # This is a pretty gnarly example! It could probably be refactored. band_name = loaf.weighted([ (1, loaf.join('', ['The ', cap_noun, 's'])), (1, loaf.join('', ['The ', adjective, ' ', cap_noun, 's'])), (1, loaf.join('', ['The ', cap_noun, ' ', cap_noun, 's'])), (1, loaf.join('', [adjective, ' ', cap_noun])), (2, loaf.join('', [cap_noun, noun])), (2, loaf.join('', [cap_noun, ' ', cap_noun])), (1, loaf.join('', [cap_noun, ' ', cap_noun, 's'])),
""" Data Loaf usage example: country song lyrics Generates horrible country songs. Steel guitar not included. """ from __future__ import print_function import dataloaf as loaf someone = loaf.weighted([ (2, 'I'), (2, 'you'), (1, "y'all"), (1, 'we'), ]) cap_someone = loaf.transform(someone, lambda x: x.capitalize()) someones = loaf.choice('my your'.split()) and_but_so = loaf.choice('and but so'.split()) to_a_place = loaf.weighted([ (1, 'on out to the pasture'), (2, 'on out to the field'), (3, loaf.join(' ', ['on out to', someones, 'ranch'])), (1, 'on out to the rodeo'), (1, 'to the general store'), (2, 'to the bar'), (1, 'to the honkytonk'), (1, 'to the hoedown'), (2, 'to the barn'), (1, "fishin'"), ]) adjective = loaf.weighted([ (2, 'drunken'), (2, 'no-good'),