Пример #1
0
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'])),
    (1, loaf.join('', [cap_noun, 's of ', uncountable_noun]))
])

if __name__ == '__main__':
    print(band_name.bake())
Пример #2
0
"""
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())
Пример #3
0
"""
Data Loaf usage example: Ghiscari names
Builds names that sound like Ghiscari characters from George R. R. Martin's
"A Song of Ice and Fire" novels.
"""
from __future__ import print_function
import dataloaf as loaf

start = loaf.choice('Gr Kr Pr Ozn Gh H N'.split())
vowel = loaf.choice('e a ah i y o'.split())
middle_consonant = loaf.choice('d l s z n zn nd'.split())
end_consonant = loaf.choice('d k l s r z n'.split())

middle = loaf.weighted([
    (1, ''),
    (2, loaf.join('', [vowel, middle_consonant])),
])
end = loaf.join('', [vowel, end_consonant])

name = loaf.join('', [start, middle, end])

zo = loaf.weighted([
    (3, 'zo'),
    (3, 'mo'),
    (1, 'na'),
])

full_name = loaf.join(' ', [name, zo, name])

if __name__ == '__main__':
    print(full_name.bake())
Пример #4
0
"""
Data Loaf usage example: coffee
Generates preposterously complex Starbucks beverages.

This example relies heavily on the WeightedLoaf to (very) roughly approximate
the frequency of the various beverage components in actual orders.
"""
from __future__ import print_function
import dataloaf as loaf

drink = loaf.weighted([
    (8, 'latte'),
    (8, 'mocha'),
    (5, 'caramel macchiato'),
    (1, 'cappuccino'),
    (5, 'white mocha'),
    (2, 'americano'),
    (1, 'chai'),
])

size = loaf.weighted([
    (1, 'short'),
    (4, 'tall'),
    (10, 'grande'),
    (5, 'venti'),
 ])

shots = loaf.weighted([
    (1, 'single'),
    (7, 'double'),
    (10, 'triple'),
Пример #5
0
"""
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'),