def local_dish(data): ''' a stew made from blip and blap ''' rules = { 'start': '#type# made with #main_ingredient# and #ingredient#', 'type': [ '#soup_adjective# soup', 'dish', 'stir-fry', 'pie', 'stew', 'spread', 'flatbread', 'dumpling', 'wrap', ], 'soup_adjective': [ 'thick', 'thin', 'clear', 'hot', 'creamy', 'rich', 'light'], 'main_ingredient': ['#meat#', '#vegetable#'], 'ingredient': ['a vegetable called #vegetable2#'], 'meat': ['%s meat' % get_latin(a['name']) \ for a in data['cuisine']['animals']] + \ ['pork', 'beef', 'lamb', 'chicken', 'game', 'fish'], 'vegetable': '<em>%s</em>' % \ get_latin(data['cuisine']['vegetables'][0]['name']), 'vegetable2': '<em>%s</em>' % \ get_latin(data['cuisine']['vegetables'][1]['name']), } grammar = tracery.Grammar(rules) sentence = grammar.flatten('#start#') return format_text(sentence)
def describe_specialty(name, product, data): ''' the city is famous for .... bread? ''' rules = { 'start': [ '#city# is #famous# for its #product#, and #superlative#.', '#product# is big business in #city#, and #superlative#.', '#city#\'s name is practically synonymous with #product#, ' \ 'and #superlative#.', ], 'product': product, 'name': get_latin(name, capitalize=True), 'city': get_latin(data['city_name'], capitalize=True), 'famous': [ 'famous', 'world renowned', 'renowned', 'known', 'known far and wide', ], 'superlative': [ 'this is the #best# destination to partake', 'there\'s no better introduction to the local specialty than ' \ '#name#', 'it doesn\'t get better than #name#', '#name# is the best in the business', ], 'best': ['best', 'number one'], } grammar = tracery.Grammar(rules) sentence = grammar.flatten('#start#') return format_text(sentence)
def regional_gem(data): ''' Gem of the Ashzvire Desert ''' climate = data['climate']['id'] gem = random.choice(['Gem', 'Jewel', 'Crown', 'Treasure', 'Pride']) region = data['terrain'] region_name = get_latin(data['geography']['region'], capitalize=True) interior_name = { 'tropical_rainforest': 'rainforest', 'tropical_monsoon': 'tropics', 'hot_desert': 'desert', 'arid': 'desert', 'steppe': 'steppe', 'subarctic': 'tundra', } if region == 'interior': if climate in interior_name: region = interior_name[climate] else: nation_types = { 'monarchy': 'Thrown', 'oligarchy': 'Empire', 'republic': 'Republic', 'theocracy': 'Nation', } region = nation_types[data['government']] region_name = get_latin(data['country'], capitalize=True) region = region[0].upper() + region[1:] return '%s of the %s %s' % (gem, region_name, region)
def activity(data): ''' Spend a Fanciful Day ''' dictionary = data['dictionary'] industries = { 'art': ['Take a Breath of Beauty', 'Find an Artist\'s Inspiration'], 'literature': ['Step into a Poem in %s' % \ data['secondary_material'][0].upper() + \ data['secondary_material'][1:]], 'death': ['Brush the Hereafter', 'Reconnect with your Ancestors'], 'technology': ['Peak at Tomorrow'], 'education': ['Study at the Seat of Knowledge', 'Learn Something New'], 'crop': ['Take a Bite of Just-Picked %s Fruit' % \ get_latin(dictionary['fruitNN'], capitalize=True), 'Stroll through the %s blossoms' % \ get_latin(data['dictionary']['fruitNN'])], 'weaving': ['Find a Bargain in the Fabric Market'], 'fishing': ['Hear the Crash of the Ocean Waves'], 'metalworking': ['Feel the Heat of an Artisan\'s Forge'], 'printing': ['A Whiff of Old Book Smell'], 'carving': ['Surround yourself with Architectural Beauty'], 'pastry': ['Savor a Freshly Baked %s Pastry' % \ get_latin(dictionary['pastryNN'], capitalize=True)], 'brewing': ['Relax with a Tangy Cup of %s' % \ get_latin(dictionary['alcoholNN'], capitalize=True)], 'ceramics': ['Spin a %s-ian Potters Wheel' % \ get_latin(data['city_name'], capitalize=True)], 'glass': ['Find Yourself Awash in Refracted Light'], } return random.choice(industries[data['industry']])
def describe_shrine(god, activity, data): ''' short description of a shrine for pins ''' rules = { 'start': 'A #descriptor# shrine to #god#.', 'descriptor': '#adjective# #material#', 'adjective': [ 'small', 'elaborate', 'popular', 'charming', 'sacred', 'tucked-away', '' * 5], 'god': [ 'the god #god_name#, who #appearance#', '#god_name#, a god who #appearance#', ], 'appearance': 'is depicted as #depiction#', 'god_name': get_latin(god['name'], capitalize=True), 'depiction': god['description'], 'material': [data['primary_material'], '' * 10], 'sacrifice': 'Look for small sacrifices of #sacrifice_item# left ' \ 'by believers.', 'sacrifice_item': [ 'blood', 'hair', 'teeth', 'fresh fruit' * 5, 'secrets', 'loose change', 'bread', 'handmade icons' * 3], 'omens': 'You may find a believer casting their fortune with '\ '#omen_object#.', 'omen_object': [ 'polished stones', 'divining cards', 'lots', 'finger bones', 'animal bones', 'stones', 'ceramic tiles', 'marble tiles', 'carved sticks'], } if activity in ['sacrifice', 'omens']: rules['start'] += ' #%s#' % activity grammar = tracery.Grammar(rules) return format_text(grammar.flatten('#start#'))
def describe_statue(data): ''' a statue in the city ''' name = data['ruler']['name'] title = data['ruler']['title'] article = 'a' if data['ruler']['multiple'] else 'the' return '%s is %s %s %s.' % ( name, article, get_latin(data['city_name'], capitalize=True), title)
def describe_temple(god, activity, data): ''' longer description of a temple and religious activity ''' materials = { 'brick': ['clay', 'ceramic'], 'straw': ['woven straw', 'woven'], 'wood': ['wooden', 'carved wood'], 'stone': ['carved stone', 'stone', 'marble', 'stone inlayed'], 'cloth': ['woven', 'tapestry'], 'glass': ['blown glass', 'glass', 'stained glass'], 'metal': ['hammered metal', 'metal', 'metal inlayed'], 'tile': ['mosaic', 'tile mosaic'], 'concrete': ['cement', 'brutalist', 'molded concrete'], } rules = { 'start': [ 'This temple, devoted to #god#, is famous for its artfully ' \ 'crafted #material# icons and decorations.', 'Believers gather at this temple #activity#.', ], 'god': [ 'the god #god_name#, who #appearance#', '#god_name#, a god who #appearance#', ], 'appearance': 'is depicted as #depiction#', 'activity': '#%s#' % activity, 'prayer': 'to pray to #god# for good fortune and health', 'oracle': 'to consult the oracle, who sits on a #secondary_material# '\ 'dais and dispenses advice and wisdom', 'posession': 'for a ceremony in which #god_name#, who is believed to '\ 'take the form of #depiction#, posesses a true believer '\ 'and acts through their body, causing them to #movement#.', 'glossolalia': 'for a ritual in which believers channel the word of '\ '#god#, and chant in a mysterious divine language.', 'sacrifice': '#prayer#', 'omen': '#prayer#', 'visions': '#prayer#', 'movement': [ 'dance', 'spasm', 'leap and cavort', 'sway and sing', 'contort into unnatural positions'], 'god_name': get_latin(god['name'], capitalize=True), 'depiction': god['description'], 'material': materials[data['primary_material']] + materials[data['secondary_material']], } grammar = tracery.Grammar(rules) return format_text(grammar.flatten('#start#'))
def beacon_of(data): ''' a beacon of innovation ''' country = get_latin(data['country']) beacon = random.choice(['Heart', 'Beacon', 'Bosom', 'Capital', 'Soul']) industries = { 'art': ['the Arts', 'Creativity', 'Artistry'], 'literature': ['Stories', 'Literature', 'the Written Word'], 'death': ['the Macabre', 'the Afterlife', 'Death'], 'technology': ['Innovation', 'Technology'], 'education': ['Thought', 'Intellect', 'Education', 'Wisdom'], 'crop': ['Taste', 'Culinary Finesse', 'Fine Cuisine'], 'weaving': ['Textile Arts', 'Fiber Arts'], 'fishing': ['the Seaside', 'Beachside Bliss'], 'metalworking': ['Industry and Craft'], 'printing': ['Literature', 'Learning', 'Publishing'], 'carving': ['Industry and Craft', 'Craftsmanship', 'Regional Craft'], 'pastry': ['Taste', 'Fine Cuisine', 'Fine Dining'], 'brewing': ['Adventure', 'Festivity'], 'ceramics': ['Industry and Craft', 'Craftsmanship', 'Regional Craft'], 'glass': ['Artistry', 'Craftsmanship'] } industry = random.choice(industries[data['industry']]) return '%s\'s %s of %s' % (country, beacon, industry)
def latin_filter(word): ''' template filter for formatting foreign words ''' return get_latin(word)
def generate_datafile(seed): ''' let's generate a city! it's hard to stay focused, so our goal can be to make: 1. notable landmarks 2. events one could attend 3. places to eat 4. survival guide ''' random.seed(seed) lang = Language() # for events, populate a calendar, and then on pageload, the appropriate # cards for time of year will show up. # the timestamp is a day in the year 2008, since 2008 is a leap year data = { 'seed': seed, 'cards': defaultdict(lambda: []), 'calendar': Calendar(), 'pins': [], } # ------------------------ GRAPH DATA ------------------------- # ''' everything that's stored in neo4j gets loaded now. the following fields depend on what is set at this point. ''' graph_dump = load_graph_data() if not graph_dump: return False data.update(graph_dump) # ----- GENERAL FACTS data['city_name'] = lang.get_word('LOC', 'city') city_name = get_latin(data['city_name'], capitalize=True) data['country'] = lang.get_word( 'LOC', 'country', definition='The country in which %s is situated' % city_name) data['city_name'].set_definition('A city in %s' % \ get_latin(data['country'], capitalize=True)) data['neighboring_city'] = lang.get_word( 'LOC', 'city2', definition='A city near %s in %s' % \ (city_name, get_latin(data['country'], capitalize=True))) data['language'] = { 'name': lang.get_word('NNP', 'language', definition='The local language'), 'stats': lang.get_stats() } # ----- GEOGRAPHY data['geography'] = { 'region': lang.get_word( 'LOC', 'region', definition='The region of %s in which %s is situated' % \ (get_latin(data['country'], capitalize=True), city_name)), 'river': lang.get_word('LOC', 'river', definition='A river in %s' % \ get_latin(data['country'], capitalize=True)), } data['geography'][data['terrain']] = lang.get_word('LOC', data['terrain']) data['geography']['neighborhoods'] = [ lang.get_word('LOC', 'neighborhood%d' % i) for i in range(15)] data['geography']['streets'] = [ lang.get_word('LOC', 'hood%d' % i) for i in range(10)] # great -- now we can have a card about language data['cards']['survive'].append('language') # economy -- this goes in the top bar, so no card data['currency'] = lang.get_word('NN', 'currency', definition='The local currency') data['exchange_rate'] = abs(random.normalvariate(0, 10)) data['bills'] = [5, 10, 15, 20, 50, 100] data['coins'] = [1, 5, 10, 100] # ----- helper functions for naming folks def get_person(identifier, title, gender_count, surname=None): ''' create a basic person bio ''' given_name = lang.get_word('NNP', identifier+'given') surname = surname or lang.get_word('NNP', identifier+'sur') fullname = get_name(given_name, surname) return { 'given_name': given_name, 'surname': surname, 'name': fullname, 'title': title, 'gender': random.randint(0, gender_count) } surname_first = bool(random.randint(0, 1)) def get_name(given_name, surname): ''' just print out the latin name of whoever ''' name = [get_latin(surname, capitalize=True), get_latin(given_name, capitalize=True)] return ' '.join(name) if surname_first else ' '.join(name[::-1]) # ----- GENDER data['genders'] = [] gender_count = random.choice([1, 2, 2, 2, 2, 3, 5]) # and make it easier to generate a random name data['get_person'] = lambda title: get_person(str(random.random()), title, gender_count) if gender_count == 2: data['genders'] = [ {'name': lang.get_word('NN', 'male')}, {'name': lang.get_word('NN', 'female')} ] elif gender_count > 2: for i in range(0, gender_count): definition = 'One of the %d genders in %s culture' % \ (gender_count, city_name) data['genders'].append( {'name': lang.get_word( 'NN', 'gender-%d' % i, definition=definition )} ) # I'm only ready with copy for non-gendered societies if gender_count == 1: data['cards']['learn'].append('gender') # misc facts data['city_age'] = random.choice([50] + [500] * 5 + [1000] * 5) data['founded'] = int(datetime.now().year - \ abs(random.normalvariate(data['city_age'], data['city_age']/2))) isolation = random.randint(4, 10) / 10.0 data['stats'] = { 'isolation': isolation, 'insularity': random.randint(int(isolation * 10), 10) / 10.0, 'population': random.randint( 1000 * isolation, int(10000000/(isolation ** 4))), 'minorities': random.randint(0, 3), 'authoritarianism': random.random(), } ruler_title = [] if data['stats']['authoritarianism'] > 0.8: data['cards']['survive'].append('authoritarianism') ruler_title += ['dictator', 'general', 'autocrat', 'head of state'] if data['stats']['authoritarianism'] > 0.97: data['advisory'] = random.sample( ['crime', 'civil unrest', 'terrorism', 'armed conflict', 'strikes and protests', 'political tension', 'risk of kidnapping'], 2) elif data['stats']['authoritarianism'] > 0.97: # watch yourself data['advisory'] = random.choice( ['risk of arrest and long-term detention', 'repressive poltiical climate']) # on the topic of government, maybe we should have related events if data['government'] == 'republic': data['calendar'].arbitrary_date('Elections! Or something like that.') ruler_title += ['president', 'prime minister'] elif data['government'] == 'monarchy': data['calendar'].arbitrary_date('A day all about the great ruler') ruler_title += [['king', 'queen'], ['emperor', 'empress']] elif data['government'] == 'oligarchy': data['calendar'].arbitrary_date('Gathering of the ruling families') ruler_title += ['cabinet member', ['lord', 'lady'], ['duke', 'dutchess']] elif data['government'] == 'theocracy': # a theocratic government should have hella religious holidays data['calendar'].recurring_event('The weekly religious observance') ruler_title += [['high priest', 'high priestess']] if data['government'] in ['monarchy', 'theocracy'] and \ random.random() > 0.7: data['calendar'].arbitrary_date('Coronation of a new ruler') # create a ruler ruler_title = random.choice(ruler_title) if isinstance(ruler_title, list): if gender_count == 2: ruler_title = random.choice(ruler_title) else: ruler_title = ruler_title[0] data['ruler'] = get_person('ruler', ruler_title, gender_count) data['ruler']['multiple'] = data['government'] == 'oligarchy' # ----- RELIGION data['religion'] = religion.get_religion(data, lang) del data['divine_structure'] del data['deity_form'] del data['deity_form_secondary'] del data['worship'] # lets have some buildings data['pins'] += attractions.describe_buildings(data, lang) # ------------------------ DESCRIPTIONS ------------------------- # # ----- FOOD data['cuisine'] = { 'fruit': cuisine.fruit(data['climate']['name']), 'tea': cuisine.tea(data['climate']['name']), 'teacup': cuisine.teacup(data['primary_material'], data['motif']), 'animals': [{'name': lang.get_word('NNP', 'critter%d' % i), 'description': wildlife.animal( data['climate']['name'], data['terrain'])} for i in range(3)], 'vegetables': [{'name': lang.get_word('NN', 'vegetable%d' % i), 'description': cuisine.vegetable()} for i in range(2)], } for veggie in data['cuisine']['vegetables']: veggie['name'].set_definition('A vegetable native to %s; %s' % \ (city_name, veggie['description'])) data['cards']['cuisine'].append('fruit') # ------- WILDLIFE data['wildlife'] = data['cuisine']['animals'][0] data['cards']['learn'].append('wildlife') # ------- FASHION if random.random() > 0.7: data['body_mod'] = fashion.body_mod(gender_count, data['motif']) data['cards']['learn'].append('style') # ----- BUILDINGS lang.get_word('NN', 'restaurant') data['cuisine']['dish'] = [] # TODO: these should be generated name_options = ['tasty', 'delicious', 'outsider'] type_options = ['restaraunt', 'cafe', 'restaurant'] for i in range(3): data['cuisine']['dish'].append({ 'name': lang.get_word('NN', 'local_dish%d' % i), 'description': cuisine.local_dish(data), }) lang.get_word('NN', 'local_dish%d' % i).set_definition( data['cuisine']['dish'][i]['description']) restaurant_name = lang.get_word('JJ', name_options[i]) restaurant_type = lang.get_word('NN', type_options[i]) data['pins'].append({ 'type': 'restaurant', 'name': '%s %s' % ( get_latin(restaurant_name, capitalize=True), get_latin(restaurant_type, capitalize=True)), 'description': restaurant.eatery( get_latin(restaurant_name, capitalize=True), data['cuisine']['dish'][i], 'restaurant', data), 'rating': get_rating(), }) if (random.random() > 0.6): lang.get_word('NN', 'teahouse', definition='Teahouse') data['pins'].append({ 'name': get_latin(lang.get_word( 'JJ', 'serene', definition='Placid; serene')) + ' Teahouse', 'type': 'teahouse', 'rating': get_rating(), }) data['cards']['cuisine'].append('teahouse') # ------------------------ DISPLAY ITEMS ------------------------- # # reformat the cards object to work with the ui data['cards'] = [{'title': 'events', 'cards': []}] + \ [{'title': c, 'cards': data['cards'][c]} for c in data['cards'] \ if data['cards'][c]] # extract the calendar into a json format data['calendar'] = data['calendar'].get_calendar() # lookup words we'll need later. doing this now instead of on the fly # so that the lang library isn't a dependency lang.get_word('NN', 'market', 'Market; shopping district') lang.get_word( 'NN', 'fruit', definition='A type of fruit native to the %s region' % \ get_latin(data['geography']['region'], capitalize=True)) lang.get_word('NN', 'pastry') lang.get_word('NN', 'alcohol') lang.get_word('NN', 'tea') lang.get_word('NN', 'hello') lang.get_word('NN', 'thanks') lang.get_word('NN', 'goodbye') lang.get_word('NN', 'sorry') lang.get_word('RB', 'where') lang.get_word('NN', 'name') lang.get_word('PRP', 'i', definition='I; first-person pronoun') lang.get_word('NN', 'coin') lang.get_word('VB', 'be', definition='To be') data['dictionary'] = lang.dictionary # ----- SLOGAN data['slogan'] = slogan(data) return data
def get_name(given_name, surname): ''' just print out the latin name of whoever ''' name = [get_latin(surname, capitalize=True), get_latin(given_name, capitalize=True)] return ' '.join(name) if surname_first else ' '.join(name[::-1])
def eatery(name, dish, category, data): ''' a charming stone hut where they serve tea ''' earliest = data['founded'] if data['founded'] > 1700 else 1700 founding = random.randint(earliest - 4, datetime.now().year - 4) materials = { 'brick': ['pottery', 'ceramic'], 'straw': ['woven straw', 'straw'], 'wood': ['wood'], 'stone': ['marble', 'stonework'], 'cloth': ['textile', 'tapestry'], 'glass': ['glass', 'stained glass'], 'metal': ['metal'], 'tile': ['mosaic', 'tile'], } rules = { # structures 'start': [ '''With a gourmet, #cuisine# menu and #vibe_part#, #name# is a #platitude#. It will have you craving perennial favorites like #dish#. The setting, in a #space#, is stunning, a perfect #city# experience.''', '''Owner #chef# has given #cuisine# cuisine a modern edge while still staying true to the regional style. The venue is stunning, a #space# and #vibe_part#. Be sure to try the #dish#.''', '''In this #vibe# #type#, you can settle down in a #space#. The menu features staples of #cuisine# cuisine, and is best known for traditional-style #dish#.''', '''#name# is a #cuisine# restaurant in #city# that's been going strong since #founding#. With a #vibe_part# and attentive service, it offers #cuisine# cuisine in a #space#.''', '''#name# is a #vibe# #type# in a welcoming environment. It offers excellent #cuisine# food. The #dish# is hard to beat.''', '''This #space# gets rave reviews for #positive# and affordable #cuisine# food and ambiance. The #vibe_part# makes it a #platitude#.''', '''#name# is one of #city#'s best #cuisine# restaurants. It's a #platitude# where you can enjoy this #space#. There are a #positive# range of dishes on offer, including #dish#.''', '''This #platitude# opened in #founding# and has set the tone for #city# cuisine ever since. Regulars like to order #dish#, sit back, and enjoy the #vibe_part#.''', '''Something of a social hub in #city#, this #vibe# #type# doesn't exactly advertise itself, but the #dish# is #positive#. Overall a #platitude#.''', '''A popular #vibe# cafe in the heart of #city# serving #dish# and drinks.''', '''Founded in early #founding#, #name# serves arguably the best know #dish# in town and it deserves that distinction. It has a #secondary_material_fancy#-decked interior and a #vibe_part#.''', '''This simple place, popular with the city workers, covers the bases for a #positive# lunch of #dish#.''', '''#name# is a rather dark and seedy place to say the least, but within its #material# walls you'll get a #positive# range of local dishes.''', '''This simple seven-table place offers #positive# breakfasts and gets packed by lunchtime -- and rightly so. The #dish# is a killer (not literally!).''', ], # info 'name': '<em>%s</em>' % name, 'type': category, 'city': '<em>%s</em>' % get_latin(data['city_name'], capitalize=True), 'neighborhood': 'the <em>%s</em> district' % get_latin(random.choice(data['geography']['neighborhoods']), capitalize=True), 'founding': str(founding), 'chef': data['get_person']('chef')['name'], # descriptive componenets 'cuisine': '<em>%s</em>ian-style' % get_latin(data['country'], capitalize=True), 'dish': '"<em>%s</em>" (a %s)' % (get_latin(dish['name']), dish['description']), 'platitude': [ 'enduring favorite', 'first-rate establishment', 'local go-to', 'local favorite', 'popular place', 'much loved #type#', 'prestigious', 'foodie oasis', ], 'vibe_part': '#vibe# #atmosphere#', 'space': [ '#stories# with #color#-painted #material# walls and #accent#', 'stylish #material# and #secondary_material# #stories#', ], 'stories': '#%s#' % data['stories'], 'single': ['building', '#type#'], 'multi': 'spacious #building#', 'many': '%s-floor #building#' % random.choice(['first', 'second', 'third', 'fourth', 'fifth', 'top']), 'accent': '#secondary_material# #accent_object#', 'accent_object': ['wall-hangings', 'doorways', 'lamps'], 'material': data['primary_material'], 'secondary_material': data['secondary_material'], 'secondary_material_fancy': materials[data['secondary_material']], 'building': ['suite', 'hall', 'room', '#type#'], # wordlists 'atmosphere': ['atmosphere', 'charm'], 'positive': [ 'top notch', 'good', 'great', 'fantastic', 'excellent', 'high caliber', 'wonderful', 'abundant' ], 'vibe': [ 'bustling', 'busy', 'relaxing', 'sophisticated', 'quaint', 'cozy', 'elegant', 'world-renowned', 'laid-back', ], 'color': ['red', 'orange', 'yellow', 'green', 'purple', 'white', 'pink'], } grammar = tracery.Grammar(rules) sentence = grammar.flatten('#start#') return format_text(sentence)
def describe_buildings(data, lang): ''' finds the right describer tool ''' pins = [] available_gods = data['religion']['gods'] for (i, building) in enumerate(data['building']): pin = {'type': building} if building == 'shrine': god = available_gods.pop() pin['name'] = '%s Shrine' % \ get_latin(god['name'], capitalize=True) pin['description'] = religion.describe_shrine( god, random.choice(data['religion']['worship']), data) elif building == 'temple': god = available_gods.pop() pin['name'] = '%s Temple' % \ get_latin(data['religion']['name'], capitalize=True) pin['description'] = religion.describe_temple( god, random.choice(data['religion']['worship']), data) elif building == 'statue': pin['name'] = 'Statue of %s' % data['ruler']['name'] pin['description'] = describe_statue(data) elif building in ['capitol', 'palace']: earliest = data['founded'] authoritarianism = data['stats']['authoritarianism'] pin['name'] = '%s %s' % (get_latin(data['country'], capitalize=True), building) # TODO: this should be it's own tracery grammar pin['description'] = \ '''Built in {date}, this imposing {material} building houses the seat of the {country} nation's government. You aren't likely to set eyes on {article} {feeling} {title}, but the building is abuzz with clerks and functionaries.'''.format( country=get_latin(data['country'], capitalize=True), date=random.randint(earliest - 1, earliest + 20), material=data['primary_material'], article='a' if data['government'] == 'oligarchy' else 'the', feeling='beloved' \ if authoritarianism < 0.5 \ else 'controversial' \ if authoritarianism > 0.7 else '', title=data['ruler']['title'] ) elif building == 'bakery': name = lang.get_word('NNP', '%s%d' % (building, i)) product = random.choice( ['bread', 'pastries', 'sweets', 'baked goods']) pin['description'] = describe_specialty(name, product, data) elif building == 'bookstore': # TODO: this deserves a longer description name = lang.get_word('NNP', '%s%d' % (building, i)) product = random.choice(['book-buying', 'reading', 'literature']) pin['name'] = '%s %s' % (get_latin(name, capitalize=True), building) pin['description'] = describe_specialty(name, product, data) elif building == 'perfumery': name = lang.get_word('NNP', '%s%d' % (building, i)) pin['name'] = '%s %s' % (get_latin(name, capitalize=True), building) pin['description'] = describe_specialty(name, 'perfume', data) elif building == 'kiln': name = lang.get_word('NNP', '%s%d' % (building, i)) pin['name'] = '%s %s' % (get_latin(name, capitalize=True), building) pin['description'] = describe_specialty(name, 'pottery', data) else: name = lang.get_word('NNP', '%s%d' % (building, i)) pin['name'] = '%s %s' % \ (get_latin(name, capitalize=True), building) pins.append(pin) return pins