{\n\t"strainname": [\n\t\t"#weedword# #weedword#",\n\t\t"#weedword# #weedword#",\n\t\t"#weedword# #weedword#",\n\t\t"#weedword# #weedword#",\n\t\t"#weedword# #weedword#",\n\t\t"#weedword# #weedword#",\n\t\t"OG #weedword#",\n\t\t"OG #weedword# #weedword#"\n\t],\n\t"origin": [\n\t\t"#strainname# #heritage# #taste# #delivers#",\n\t\t"#strainname# #heritage# #delivers# #taste#",\n\t\t"#strainname# #heritage# #taste# #delivers# #medical#",\n\t\t"#strainname# #heritage# #taste# #delivers# #award#",\n\t\t"#strainname# #heritage# #taste# #delivers#"\n\t],\n\t"heritage": [\n\t\t"is a #descriptor# #satin# made from crossing #strainname# and #strainname#.",\n\t\t"is a #satin# made from a cross between the #descriptor# #strainname# and #strainname#.",\n\t\t"is a rare #satin# made from crossing #strainname# and #strainname#.",\n\t\t"#secretorigin#"\n\t],\n\t"satin": [\n\t\t"sativa",\n\t\t"indica",\n\t\t"hybrid"\n\t],\n\t"descriptor": [\n\t\t"potent",\n\t\t"rare"\n\t],\n\t"taste": [\n\t\t"This strain's #buddescription# buds fill the room with scents of #flavor# and #flavor#.",\n\t\t"This strain tastes of #flavor# with #flavor# influence.",\n\t\t"This strain tastes distinctly of #flavor#.",\n\t\t"This strain tastes like #flavor#.",\n\t\t"This strain has a #flavor# flavor profile with surprising notes of #flavor#.",\n\t\t"This strain has big, bold #flavor# flavors with undertones of #flavor#."\n\t],\n\t"flavor": [\n\t\t"gooseberry",\n\t\t"lychee",\n\t\t"cherry",\n\t\t"despair",\n\t\t"banana",\n\t\t"cinnamon",\n\t\t"licorice",\n\t\t"savory herb",\n\t\t"citrus",\n\t\t"blackberry",\n\t\t"blue coconut",\n\t\t"caramel",\n\t\t"cherry",\n\t\t"chocolate",\n\t\t"cotton candy",\n\t\t"lemon",\n\t\t"lime",\n\t\t"grape",\n\t\t"green apple",\n\t\t"lemonberry",\n\t\t"diet cherry",\n\t\t"mango",\n\t\t"mint",\n\t\t"orange",\n\t\t"peach",\n\t\t"raspberry",\n\t\t"sour blue raspberry",\n\t\t"strawberry",\n\t\t"watermelon",\n\t\t"chicken",\n\t\t"goose",\n\t\t"duck",\n\t\t"quail",\n\t\t"guinea hen",\n\t\t"salmon",\n\t\t"tilapia",\n\t\t"beef",\n\t\t"lamb",\n\t\t"pork",\n\t\t"mutton",\n\t\t"rabbit",\n\t\t"veal",\n\t\t"venison",\n\t\t"açai berry",\n\t\t"apple",\n\t\t"apricot",\n\t\t"avocado",\n\t\t"banana",\n\t\t"bilberry",\n\t\t"black raspberry",\n\t\t"blackberry",\n\t\t"blackcurrant",\n\t\t"blood orange",\n\t\t"blueberry",\n\t\t"boysenberry",\n\t\t"cantaloupe",\n\t\t"cantaloupe",\n\t\t"cherimoya",\n\t\t"cherry",\n\t\t"clementine",\n\t\t"cloudberry",\n\t\t"coconut",\n\t\t"cranberry",\n\t\t"currant",\n\t\t"date",\n\t\t"dragonfruit",\n\t\t"durian",\n\t\t"elderberry",\n\t\t"feijoa",\n\t\t"fig",\n\t\t"goji berry",\n\t\t"gooseberry",\n\t\t"grape",\n\t\t"grapefruit",\n\t\t"guava",\n\t\t"honeydew",\n\t\t"huckleberry",\n\t\t"jabouticaba",\n\t\t"jackfruit",\n\t\t"jambul",\n\t\t"jujube",\n\t\t"juniper berry",\n\t\t"kiwano",\n\t\t"kiwi fruit",\n\t\t"kumquat",\n\t\t"lemon",\n\t\t"lime",\n\t\t"loquat",\n\t\t"lychee",\n\t\t"mandarine",\n\t\t"mango",\n\t\t"marion berry",\n\t\t"melon",\n\t\t"miracle fruit",\n\t\t"mulberry",\n\t\t"nectarine",\n\t\t"olive",\n\t\t"orange",\n\t\t"papaya",\n\t\t"passionfruit",\n\t\t"peach",\n\t\t"pear",\n\t\t"persimmon",\n\t\t"physalis",\n\t\t"pineapple",\n\t\t"plum",\n\t\t"pomegranate",\n\t\t"pomelo",\n\t\t"pumpkin",\n\t\t"purple mangosteen",\n\t\t"quince",\n\t\t"raisin",\n\t\t"rambutan",\n\t\t"raspberry",\n\t\t"redcurrant",\n\t\t"salal berry",\n\t\t"salmon berry",\n\t\t"satsuma",\n\t\t"squash",\n\t\t"star fruit",\n\t\t"strawberry",\n\t\t"tamarillo",\n\t\t"tangerine",\n\t\t"tomato",\n\t\t"ugli fruit",\n\t\t"watermelon",\n\t\t"acorn squash",\n\t\t"alfalfa sprouts",\n\t\t"amaranth",\n\t\t"artichoke",\n\t\t"arugula",\n\t\t"asparagus",\n\t\t"azuki beans",\n\t\t"banana squash",\n\t\t"bean sprouts",\n\t\t"beet",\n\t\t"black beans",\n\t\t"black-eyed peas",\n\t\t"bok choy",\n\t\t"borlotti bean",\n\t\t"broad beans",\n\t\t"broccoflower",\n\t\t"broccoli",\n\t\t"brussels sprouts",\n\t\t"butternut squash",\n\t\t"cabbage",\n\t\t"calabrese",\n\t\t"cannabis",\n\t\t"carrot",\n\t\t"carrots",\n\t\t"cauliflower",\n\t\t"celeriac",\n\t\t"celery",\n\t\t"plastic",\n\t\t"horsey",\n\t\t"old bones",\n\t\t"charcoal",\n\t\t"tennis ball",\n\t\t"cigar box",\n\t\t"blanched almond",\n\t\t"cherry blossom",\n\t\t"plutonium",\n\t\t"grape",\n\t\t"grape",\n\t\t"grape",\n\t\t"grape",\n\t\t"toxic waste",\n\t\t"peat",\n\t\t"dirt",\n\t\t"soil",\n\t\t"human sweat",\n\t\t"hemlock",\n\t\t"arsenic",\n\t\t"aluminum",\n\t\t"anime body pillows",\n\t\t"rusty",\n\t\t"Flintstone vitamins",\n\t\t"ass"\n\t],\n\t"buddescription": [\n\t\t"chunky",\n\t\t"sticky",\n\t\t"resin-covered",\n\t\t"crystal-coated",\n\t\t"fluffy"\n\t],\n\t"delivers": [\n\t\t"It delivers #effect# and #effect# feelings.",\n\t\t"It leaves you feeling #effect#.",\n\t\t"It's beloved for its #effect# feelings.",\n\t\t"It will leave you feeling #effect# and #effect#.",\n\t\t"Its high THC and CBD levels will leave you feeling #effect#."\n\t],\n\t"effect": [\n\t\t"creative",\n\t\t"energetic",\n\t\t"euphoric",\n\t\t"focused",\n\t\t"giggly",\n\t\t"happy",\n\t\t"hungry",\n\t\t"relaxed",\n\t\t"sleepy",\n\t\t"talkative",\n\t\t"tingly",\n\t\t"uplifted"\n\t],\n\t"secretorigin": [\n\t\t"is a #satin# strain with secret origins.",\n\t\t"is a true hybrid strain."\n\t],\n\t"medical": [\n\t\t"Medical patients use it for symptoms of #symptom# and #symptom#.",\n\t\t"Medical users find it especially helpful for #symptom#."\n\t],\n\t"symptom": [\n\t\t"chronic pain",\n\t\t"appetite loss",\n\t\t"nausea",\n\t\t"stress",\n\t\t"migraines"\n\t],\n\t"award": [\n\t\t"It was awarded the #nameaward#."\n\t],\n\t"nameaward": [\n\t\t"#place# #year# Cannabis Cup",\n\t\t"High Times #year# Best In Show",\n\t\t"First Place in#year# #place# Cannabis Fest",\n\t\t"#place# Kièf de Résistance"\n\t],\n\t"year": [\n\t\t"2000",\n\t\t"2001",\n\t\t"2002",\n\t\t"2003",\n\t\t"2004",\n\t\t"2005",\n\t\t"2006",\n\t\t"2007",\n\t\t"2008",\n\t\t"2009",\n\t\t"2010",\n\t\t"2011",\n\t\t"2012",\n\t\t"2013",\n\t\t"2014",\n\t\t"2015",\n\t\t"2016",\n\t\t"2017",\n\t\t"2018",\n\t\t"2019",\n\t\t"2020",\n\t\t"2021",\n\t\t"2022"\n\t],\n\t"place": [\n\t\t"Alabama",\n\t\t"Alaska",\n\t\t"Arizona",\n\t\t"Arkansas",\n\t\t"California",\n\t\t"Colorado",\n\t\t"Connecticut",\n\t\t"Delaware",\n\t\t"Florida",\n\t\t"Georgia",\n\t\t"Hawaii",\n\t\t"Idaho",\n\t\t"Illinois",\n\t\t"Indiana",\n\t\t"Iowa",\n\t\t"Kansas",\n\t\t"Kentucky",\n\t\t"Louisiana",\n\t\t"Maine",\n\t\t"Maryland",\n\t\t"Massachusetts",\n\t\t"Michigan",\n\t\t"Minnesota",\n\t\t"Mississippi",\n\t\t"Missouri",\n\t\t"Montana",\n\t\t"Nebraska",\n\t\t"Nevada",\n\t\t"New Hampshire",\n\t\t"New Jersey",\n\t\t"New Mexico",\n\t\t"New York",\n\t\t"North Carolina",\n\t\t"North Dakota",\n\t\t"Ohio",\n\t\t"Oklahoma",\n\t\t"Oregon",\n\t\t"Pennsylvania",\n\t\t"Rhode Island",\n\t\t"South Carolina",\n\t\t"South Dakota",\n\t\t"Tennessee",\n\t\t"Texas",\n\t\t"Utah",\n\t\t"Vermont",\n\t\t"Virginia",\n\t\t"Washington",\n\t\t"West Virginia",\n\t\t"Wisconsin",\n\t\t"Wyoming",\n\t\t"Alberta",\n\t\t"British Columbia",\n\t\t"Manitoba",\n\t\t"New Brunswick",\n\t\t"Newfoundland and Labrador",\n\t\t"Northwest Territories",\n\t\t"Nova Scotia",\n\t\t"Nunavut",\n\t\t"Ontario",\n\t\t"Prince Edward Island",\n\t\t"Quebec",\n\t\t"Saskatchewan",\n\t\t"Yukon"\n\t],\n\t"weedword": [\n\t\t"Alice",\n\t\t"Alien",\n\t\t"Allen",\n\t\t"Alpha",\n\t\t"Ambrosia",\n\t\t"Amnesia",\n\t\t"Ancient",\n\t\t"Anesthesia",\n\t\t"Angel",\n\t\t"Animal",\n\t\t"Ape",\n\t\t"Apollo",\n\t\t"Appalachia",\n\t\t"Apple",\n\t\t"Arabian",\n\t\t"Armageddon",\n\t\t"Arrow",\n\t\t"Atomic",\n\t\t"Aurora",\n\t\t"Avalon",\n\t\t"Avi-Dekel",\n\t\t"BC",\n\t\t"Ball",\n\t\t"Banana",\n\t\t"Banner",\n\t\t"Barbara",\n\t\t"Bastard",\n\t\t"Bay",\n\t\t"Bayou",\n\t\t"Bean",\n\t\t"Beer",\n\t\t"Belladonna",\n\t\t"Berkely",\n\t\t"Berry",\n\t\t"Big",\n\t\t"Bilbo",\n\t\t"Bio-Diesel",\n\t\t"Bio-Jesus",\n\t\t"Blackberry",\n\t\t"Bliss",\n\t\t"Blockhead",\n\t\t"Blue",\n\t\t"Blueberry",\n\t\t"Boggle",\n\t\t"Bomb",\n\t\t"Bordello",\n\t\t"Boss",\n\t\t"Box",\n\t\t"Boy",\n\t\t"Boysenberry",\n\t\t"Brains",\n\t\t"Brainstorm",\n\t\t"Bread",\n\t\t"Breath",\n\t\t"Broke",\n\t\t"Bruce",\n\t\t"Bubba",\n\t\t"Bubbleberry",\n\t\t"Bubblegum",\n\t\t"Bubblegun",\n\t\t"Bubblicious",\n\t\t"Bud",\n\t\t"Bullrider",\n\t\t"Burmese",\n\t\t"Butter",\n\t\t"Butterscotch",\n\t\t"C13",\n\t\t"Cactus",\n\t\t"Cadillac",\n\t\t"Caesar",\n\t\t"Cali",\n\t\t"Calm",\n\t\t"Candy",\n\t\t"Candyland",\n\t\t"Cane",\n\t\t"Cannadential",\n\t\t"Cannalope",\n\t\t"Cannatonic",\n\t\t"Caramelicious",\n\t\t"Casey",\n\t\t"Cat",\n\t\t"Cataract",\n\t\t"Central",\n\t\t"Champagne",\n\t\t"Charlotte's",\n\t\t"Charms",\n\t\t"Cheese",\n\t\t"Cheesecake",\n\t\t"Chem",\n\t\t"Chemdawg",\n\t\t"Cherry",\n\t\t"Chiesel",\n\t\t"Chocolate",\n\t\t"Chocolope",\n\t\t"Chung",\n\t\t"Chunk",\n\t\t"Church",\n\t\t"Cinderella",\n\t\t"Cinex",\n\t\t"Citrus",\n\t\t"Cleaner",\n\t\t"Coast",\n\t\t"Cold",\n\t\t"Colorado",\n\t\t"Coma",\n\t\t"Confidential",\n\t\t"Congolese",\n\t\t"Connecticut",\n\t\t"Connie",\n\t\t"Cookies",\n\t\t"Corleone",\n\t\t"Cotton",\n\t\t"Cough",\n\t\t"Crack",\n\t\t"Cracker",\n\t\t"Crazy",\n\t\t"Cream",\n\t\t"Creek",\n\t\t"Crimea",\n\t\t"Crush",\n\t\t"Crystal",\n\t\t"DJ",\n\t\t"Dahlia",\n\t\t"Dairy",\n\t\t"Damage",\n\t\t"Danky",\n\t\t"Dark",\n\t\t"Darth",\n\t\t"Dawg",\n\t\t"Daydream",\n\t\t"Deadhead",\n\t\t"Death",\n\t\t"Deep",\n\t\t"Delight",\n\t\t"Denver",\n\t\t"Devil",\n\t\t"Diablo",\n\t\t"Diamond",\n\t\t"Dick",\n\t\t"Diesel",\n\t\t"Dieseltonic",\n\t\t"Digweed",\n\t\t"Dimension",\n\t\t"Doe",\n\t\t"Dog",\n\t\t"Dogwalker",\n\t\t"Domina",\n\t\t"Domino",\n\t\t"Donna",\n\t\t"Doodle",\n\t\t"Door",\n\t\t"Dopium",\n\t\t"Dorit",\n\t\t"Double",\n\t\t"Dr.",\n\t\t"Dragon",\n\t\t"Dreadlock",\n\t\t"Dream",\n\t\t"Drop",\n\t\t"Duff",\n\t\t"Duke",\n\t\t"Durban",\n\t\t"Dutch",\n\t\t"Duty",\n\t\t"Dwarf",\n\t\t"Dynamite",\n\t\t"Early",\n\t\t"Earth",\n\t\t"Earthquake",\n\t\t"East",\n\t\t"Ed",\n\t\t"Eddy",\n\t\t"Edelweiss",\n\t\t"El",\n\t\t"El-Na",\n\t\t"Elderberry",\n\t\t"Electric",\n\t\t"Endless",\n\t\t"Enigma",\n\t\t"Eran",\n\t\t"Erez",\n\t\t"Euphoria",\n\t\t"Ewok",\n\t\t"Exodus",\n\t\t"Express",\n\t\t"Extreme",\n\t\t"Eye",\n\t\t"Fantasy",\n\t\t"Fields",\n\t\t"Finest",\n\t\t"Fire",\n\t\t"Flash",\n\t\t"Flav",\n\t\t"Flourish",\n\t\t"Flower",\n\t\t"Flowerbomb",\n\t\t"Freezeland",\n\t\t"Frost",\n\t\t"Frostbite",\n\t\t"Frosty",\n\t\t"Fruit",\n\t\t"Fruity",\n\t\t"Fuck",\n\t\t"Fucking",\n\t\t"Fuel",\n\t\t"Funky",\n\t\t"G",\n\t\t"G13",\n\t\t"Gate",\n\t\t"Ghost",\n\t\t"Gift",\n\t\t"Girl",\n\t\t"Glass",\n\t\t"Glue",\n\t\t"Goat",\n\t\t"Goblin",\n\t\t"God",\n\t\t"Godberry",\n\t\t"Goddess",\n\t\t"Godfather",\n\t\t"God's",\n\t\t"Gog",\n\t\t"Gold",\n\t\t"Goldberry",\n\t\t"Golden",\n\t\t"Goldwing",\n\t\t"Goo",\n\t\t"Gorilla",\n\t\t"Grail",\n\t\t"Grand",\n\t\t"Granddaddy",\n\t\t"Grape",\n\t\t"Grapefruit",\n\t\t"Grapes",\n\t\t"Gravity",\n\t\t"Green",\n\t\t"Grinspoon",\n\t\t"Guava",\n\t\t"Gum",\n\t\t"Gumbo",\n\t\t"Guy",\n\t\t"Harlequin",\n\t\t"Harmony",\n\t\t"Hash",\n\t\t"Hashberry",\n\t\t"Hashplant",\n\t\t"Hawaiian",\n\t\t"Haze",\n\t\t"Head",\n\t\t"Headband",\n\t\t"Headbanger",\n\t\t"Heavy",\n\t\t"Hells",\n\t\t"Helper",\n\t\t"Hempstar",\n\t\t"Herer",\n\t\t"Herojuana",\n\t\t"Himalayan",\n\t\t"Hindu",\n\t\t"Hippie",\n\t\t"Hog",\n\t\t"Hog's",\n\t\t"Holistic",\n\t\t"Hollands",\n\t\t"Holy",\n\t\t"Hong",\n\t\t"Hope",\n\t\t"Hornet",\n\t\t"Huckleberry",\n\t\t"Humboldt",\n\t\t"Hustle",\n\t\t"Hydro",\n\t\t"Ice",\n\t\t"Incredible",\n\t\t"Ingrid",\n\t\t"Island",\n\t\t"Ivy",\n\t\t"J-27",\n\t\t"J1",\n\t\t"JT15",\n\t\t"Jack",\n\t\t"Jack's",\n\t\t"Jagermeister",\n\t\t"Jane",\n\t\t"Jean",\n\t\t"Jedi",\n\t\t"Jesus",\n\t\t"Jilly",\n\t\t"Johnny's",\n\t\t"Jones",\n\t\t"Juicy",\n\t\t"Juliet",\n\t\t"Julius",\n\t\t"Jupiter",\n\t\t"K",\n\t\t"K1",\n\t\t"Kaboom",\n\t\t"Kahuna",\n\t\t"Kali",\n\t\t"Kandahar",\n\t\t"Key",\n\t\t"Khola",\n\t\t"Killer",\n\t\t"Killing",\n\t\t"Kimbo",\n\t\t"King",\n\t\t"Kings",\n\t\t"King's",\n\t\t"Kola",\n\t\t"Kong",\n\t\t"Kosher",\n\t\t"Kryptonite",\n\t\t"Kush",\n\t\t"Kushadelic",\n\t\t"Kushage",\n\t\t"Kushashima",\n\t\t"Kushberry",\n\t\t"LA",\n\t\t"LAPD",\n\t\t"LSD",\n\t\t"LVPK",\n\t\t"La",\n\t\t"Label",\n\t\t"Lambo",\n\t\t"Lamb's",\n\t\t"Larry",\n\t\t"Laughing",\n\t\t"Lavender",\n\t\t"Leaf",\n\t\t"Lemon",\n\t\t"Lepp",\n\t\t"Lethal",\n\t\t"Liberty",\n\t\t"Lifesaver",\n\t\t"Lightning",\n\t\t"Lights",\n\t\t"Lime",\n\t\t"Limeade",\n\t\t"Lions",\n\t\t"Liquid",\n\t\t"Little",\n\t\t"Loud",\n\t\t"Louis",\n\t\t"Lowryder",\n\t\t"Lucky",\n\t\t"Lyme",\n\t\t"M-39",\n\t\t"MK",\n\t\t"Mad",\n\t\t"Man",\n\t\t"Mango",\n\t\t"Manitoba",\n\t\t"Maple",\n\t\t"Mars",\n\t\t"Martian",\n\t\t"Mass",\n\t\t"Master",\n\t\t"Matanuska",\n\t\t"Matsu",\n\t\t"Maui",\n\t\t"Mazar",\n\t\t"Mean",\n\t\t"Medicine",\n\t\t"Mercury",\n\t\t"Midnight",\n\t\t"Millennium",\n\t\t"Mint",\n\t\t"Mist",\n\t\t"Misty",\n\t\t"Mob",\n\t\t"Moby",\n\t\t"Monkey",\n\t\t"Monster",\n\t\t"Moonshine",\n\t\t"Mossimo",\n\t\t"Mother's",\n\t\t"Mr.",\n\t\t"Mystic",\n\t\t"N",\n\t\t"NYC",\n\t\t"Nebula",\n\t\t"Negra",\n\t\t"Nelson",\n\t\t"Nepal",\n\t\t"Neptune",\n\t\t"Nice",\n\t\t"Night",\n\t\t"Niño",\n\t\t"Noir",\n\t\t"Nordle",\n\t\t"Northern",\n\t\t"Nuggetry",\n\t\t"Nukem",\n\t\t"OCD",\n\t\t"OG",\n\t\t"OGiesel",\n\t\t"Obama",\n\t\t"Odyssey",\n\t\t"Old",\n\t\t"Orange",\n\t\t"Organic",\n\t\t"Outer",\n\t\t"P-91",\n\t\t"PVC",\n\t\t"Panama",\n\t\t"Pandora's",\n\t\t"Papaya",\n\t\t"Paris",\n\t\t"Passion",\n\t\t"Pearl",\n\t\t"Pebbles",\n\t\t"Pennywise",\n\t\t"Permafrost",\n\t\t"Pez",\n\t\t"Pie",\n\t\t"Pineapple",\n\t\t"Pink",\n\t\t"Piss",\n\t\t"Pitbull",\n\t\t"Plant",\n\t\t"Platinum",\n\t\t"Plum",\n\t\t"Plushberry",\n\t\t"Pluto",\n\t\t"Poison",\n\t\t"Popcorn",\n\t\t"Pot",\n\t\t"Power",\n\t\t"Pre-98",\n\t\t"Presidential",\n\t\t"Princess",\n\t\t"Punch",\n\t\t"Pure",\n\t\t"Purple",\n\t\t"Purps",\n\t\t"Q3",\n\t\t"Qleaner",\n\t\t"Qrazy",\n\t\t"Quake",\n\t\t"Quebec",\n\t\t"Queen",\n\t\t"Querkle",\n\t\t"Rafael",\n\t\t"Rainbow",\n\t\t"Rascal",\n\t\t"Raspberry",\n\t\t"Recon",\n\t\t"Red",\n\t\t"Redding",\n\t\t"Redwood",\n\t\t"Remedy",\n\t\t"Rene",\n\t\t"Rhino",\n\t\t"Ribbon",\n\t\t"Rich",\n\t\t"Richie",\n\t\t"Ripper",\n\t\t"Roadkill",\n\t\t"Rocket",\n\t\t"Rocklock",\n\t\t"Rockstar",\n\t\t"Romping",\n\t\t"Romulan",\n\t\t"Root",\n\t\t"Rosenthal",\n\t\t"Royal",\n\t\t"Russian",\n\t\t"SAGE",\n\t\t"SFV",\n\t\t"Sage",\n\t\t"Sapphire",\n\t\t"Satellite",\n\t\t"Saturn",\n\t\t"Scout",\n\t\t"Seattle",\n\t\t"Shack",\n\t\t"Shaman",\n\t\t"Shark",\n\t\t"Sharksbreath",\n\t\t"Sherbert",\n\t\t"Shipwreck",\n\t\t"Shock",\n\t\t"Shoreline",\n\t\t"Short",\n\t\t"Sierra",\n\t\t"Silver",\n\t\t"Silverback",\n\t\t"Sister",\n\t\t"Skellington",\n\t\t"Skunk",\n\t\t"Skunky",\n\t\t"Sky",\n\t\t"Skywalker",\n\t\t"Slipper",\n\t\t"Smelliot",\n\t\t"Snoop's",\n\t\t"Snow",\n\t\t"Snowcap",\n\t\t"Soda",\n\t\t"Somango",\n\t\t"Sour",\n\t\t"South",\n\t\t"Space",\n\t\t"Spades",\n\t\t"Star",\n\t\t"Stardawg",\n\t\t"Starry",\n\t\t"Stevie",\n\t\t"Stik",\n\t\t"Strawberry",\n\t\t"Sugar",\n\t\t"Sunset",\n\t\t"Sunshine",\n\t\t"Super",\n\t\t"Superman",\n\t\t"Supernova",\n\t\t"Superstar",\n\t\t"Surfer",\n\t\t"Sweet",\n\t\t"Swiss",\n\t\t"THC",\n\t\t"Tang",\n\t\t"Tangerine",\n\t\t"Tangie",\n\t\t"Thaidal",\n\t\t"Thin",\n\t\t"Third",\n\t\t"Thunder",\n\t\t"Tiger",\n\t\t"Timewreck",\n\t\t"Tonic",\n\t\t"Tooth",\n\t\t"Train",\n\t\t"Trainwreck",\n\t\t"Tranquil",\n\t\t"Treat",\n\t\t"Tres",\n\t\t"Trident",\n\t\t"Trifecta",\n\t\t"Triple",\n\t\t"Tropical",\n\t\t"Tropicali",\n\t\t"True",\n\t\t"Truth",\n\t\t"Tuna",\n\t\t"Twista",\n\t\t"UK",\n\t\t"UW",\n\t\t"Ultimate",\n\t\t"Ultra",\n\t\t"Unwind",\n\t\t"Urkle",\n\t\t"Vader",\n\t\t"Vanilla",\n\t\t"Velvet",\n\t\t"Venice",\n\t\t"Venom",\n\t\t"Verde",\n\t\t"Very",\n\t\t"Void",\n\t\t"Voodoo",\n\t\t"Vortex",\n\t\t"Waldo",\n\t\t"Walker",\n\t\t"Walrus",\n\t\t"Waltz",\n\t\t"Warlock",\n\t\t"Wave",\n\t\t"Web",\n\t\t"White",\n\t\t"Who",\n\t\t"Widow",\n\t\t"Willie",\n\t\t"Willy",\n\t\t"Willy's",\n\t\t"Woman",\n\t\t"Wonder",\n\t\t"Wonderland",\n\t\t"Wonka",\n\t\t"Wonka's",\n\t\t"Woods",\n\t\t"Woody",\n\t\t"Wreck",\n\t\t"Wrench",\n\t\t"XIII",\n\t\t"XJ-13",\n\t\t"XXX",\n\t\t"Y",\n\t\t"Yoda",\n\t\t"Yumboldt",\n\t\t"Zombie"\n\t]\n}
v.2016-09-05
//requires jquery\n\n// input: an array of objects\n//\t\t a property that each of those object have\n// output: an array of the properties of all the objects\nwindow.skimObjectArray = function(objectArray, property){\n\tconsole.log("skimObjectArray(", "objectArray", objectArray, "property", property, ")")\n\tvar values = [];\n\n\tfor (var i = 0; i < objectArray.length; i++) {\n\t\tvar thingToAdd = objectArray[i][property];\n\t\tif(typeof thingToAdd === "object"){\n\t\t\t// i hope to god this works\n\t\t\tthingToAdd = objectArray[i][property].join("\sn")\n\t\t}\n\t\tvalues.push( thingToAdd );\n\t};\n\n\tvalues = values.join("\sn");\n\tvalues = values.split("\sn")\n\n\treturn values;\n}\n\nStory.prototype.appendCorpora = function(){\n\tvar corporaToAppend = tale.lookup("tags", "corpus");\n\tif(!corporaToAppend.length) return;\n\n\tfor(var i in corporaToAppend){\n\t\tvar currentPassage = corporaToAppend[i].title;\n\n\t\t// the rules are the concatenation of each symbol in this passage\n\t\tvar rules = [];\n\t\tvar lines = tale.passages[currentPassage].text.split("\sn")\n\t\tfor(var j in lines){\n\t\t\tvar line = lines[j];\n\t\t\tvar location = line.split("#");\n\t\t\tconsole.log("location: ", location);\n\t\t\tvar corpusLocation = location[0];\n\n\t\t\t// fetch me that sweet sweet boy\n\t\t\tvar corpus = $.ajax({\n\t\t\t\tdataType: "json",\n\t\t\t\turl: corpusLocation,\n\t\t\t\tasync: false\n\t\t\t});\n\t\t\tcorpus = corpus.responseJSON;\n\n\t\t\t// drill down to the array we want\n\t\t\tfor (var i = 1; i < location.length; i++) {\n\t\t\t\tconsole.log("corpus: ", corpus);\n\t\t\t\t// if there's a ! at the beginning of a location, skim the objArray for that property\n\t\t\t\tif(location[i][0] === "!"){\n\t\t\t\t\tcorpus = skimObjectArray(corpus, location[i].substring(1));\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tcorpus = corpus[ location[i] ]\n\t\t\t};\n\n\t\t\tconsole.log("corpus: ", corpus);\n\t\t\t// add this into the symbol-in-progress\n\t\t\trules = rules.concat(corpus);\n\t\t\tconsole.log("rules: ", rules)\n\t\t}\n\n\t\t// the name of this symbol is the name of the passage\n\t\tvar finalJSON = "{ \s"" + currentPassage + "\s": " + JSON.stringify(rules) + " }";\n\n\t\t// save our dark deeds to the passage\n\t\ttale.passages[currentPassage].text = finalJSON;\n\n\t\t//tag this as JSON so it gets appended in the next step\n\t\ttale.passages[currentPassage].tags.push("JSON")\n\t}\n\n\tconsole.log("corpora loaded")\n}\n\nStory.prototype.appendJSON = function() {\n\tvar JSONtoAppend = tale.lookup("tags", "JSON");\n\tif(!JSONtoAppend.length) return;\n\n\tfor(i in JSONtoAppend){\n\t\tvar newJSON = JSON.parse(JSONtoAppend[i].text);\n\t\t$.extend(this.data, newJSON);\n\t}\n\tconsole.log("JSON appended");\n}\n\nfunction Story(){\n\tvar grammars = tale.lookup("tags", "grammar", "title");\n\tthis.data = {};\n\n\tvar links = /(\s[\s[\sb)(.+?)(\sb\s]\s])/g;\n\tvar sublinks = /([^\s[\s]]+)*(.+)/\n\n\tfunction convertSyntax(match, p1, p2, p3){\n\t\t// If a passage is invoked that's tagged as a grammar, change Twine links into Tracery symbols.\n\t\t// e.g.: [[animal]] => #animal#\n\t\t// e.g.: [[animal][capitalize]] => #animal.capitalize#\n\n\t\t// p1 is left brackets, p3 is right brackets\n\t\tvar targetLink = p2.split("][")[0];\n\t\tvar modifiers = p2.split("][").slice(1, p2.length).join(".");\n\t\tmodifiers = modifiers?("." + modifiers):"";\n\t\t\n\t\tvar trace = "#" + targetLink + modifiers + "#";\n\t\t\n\t\tvar linkIsGrammar = false;\n\t\tvar tags = tale.get(targetLink).tags\n\t\tfor(var i = 0; i < tags.length; i++){\n\t\t\tif(tags[i] == "grammar" || tags[i] == "corpus"){\n\t\t\t\tlinkIsGrammar = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\treturn linkIsGrammar?trace:match;\n\t}\n\n\tfor(var i in grammars){\n\t\tif(grammars[i] == undefined) continue;\n\n\t\t// Passage names become grammar names, Passage text becomes grammar text. \n\t\tvar newSymbol = grammars[i].title\n\t\tvar newText = grammars[i].text\n\n\t\tvar link = /(\s[\s[\sb)(.+?)(\sb\s]\s])/g;\n\t\tnewText = newText.replace(link, convertSyntax);\n\t\t// Get everything that's being linked to.\n\n\t\tthis.data[newSymbol] = newText.split('\sn');\n\t}\n\n\tthis.appendCorpora();\n\tthis.appendJSON();\n\tconsole.log("Story: ", this);\n}\nStory.prototype.constructor = Story;\n\n// Append this to the tale object because I don't know where else to put it.\nTale.prototype.story = new Story();\n\nStory.prototype.toHTML = function() {\n\tvar output = [];\n\tvar tab = " ";\n\tvar beg = '\sn' + tab + "\s"<span class=\s"grammarContents\s">{{{"\n\tvar end = "}}}</span>\s""\n\n\tfor(var i in this.data){\n\t\tvar gram = "<span class=\s"grammarTitle\s">\s"" + i + "\s"</span>: [";\n\t\tgram += beg + this.data[i].join(end + ',' + beg) + end;\n\t\tgram += "]";\n\t\toutput.push(gram);\n\t}\n\treturn "{\sn" + output.join(",\sn") + "\sn}";\n}\n\nTale.prototype.JSONtoTwee = function() {\n\tvar JSONtoConvert = tale.lookup("tags", "JSON");\n\tvar combinedJSON = ""\n\n\tfor (var i in JSONtoConvert){\n\t\tcombinedJSON += JSONtoConvert[i].text;\n\t}\n\n\t// Note the {{{}}} delimiters in textPost. This is intended for display in Twine, so\n\t// if you're just running these raw they aren't necessary.\n\tvar regex = {titlesPre: /\st"(.+)": \s[/g, titlesPost: "<br>:: $1 [grammar]",\n\t\t\t\t textPre: /\st*"(.+)",*(?:\sn\st)?(?:\s],)*\sn/g, textPost: "{{{$1}}}<br>"}\n\n\tvar tweeOutput = combinedJSON.replace(regex.titlesPre, regex.titlesPost);\n\ttweeOutput = tweeOutput.replace(regex.textPre, regex.textPost);\n\ttweeOutput = tweeOutput.replace(/({\sn)|(]\sn})/g, "")\n\n\treturn tweeOutput;\n}
window.tracery = {\n utilities : {}\n};\n\n(function () {/**\n * @author Kate Compton\n */\n\nfunction inQuotes(s) {\n return '"' + s + '"';\n};\n\nfunction parseAction(action) {\n return action;\n};\n\n// tag format\n// a thing to expand, plus actions\n\nfunction parseTag(tag) {\n var errors = [];\n var prefxns = [];\n var postfxns = [];\n\n var lvl = 0;\n var start = 0;\n\n var inPre = true;\n\n var symbol,\n mods;\n\n function nonAction(end) {\n if (start !== end) {\n var section = tag.substring(start, end);\n if (!inPre) {\n errors.push("multiple possible expansion symbols in tag!" + tag);\n } else {\n inPre = false;\n var split = section.split(".");\n symbol = split[0];\n mods = split.slice(1, split.length);\n }\n\n }\n start = end;\n };\n\n for (var i = 0; i < tag.length; i++) {\n var c = tag.charAt(i);\n\n switch(c) {\n case '[':\n if (lvl === 0) {\n nonAction(i);\n }\n\n lvl++;\n break;\n case ']':\n lvl--;\n if (lvl === 0) {\n var section = tag.substring(start + 1, i);\n if (inPre)\n prefxns.push(parseAction(section));\n else\n postfxns.push(parseAction(section));\n start = i + 1;\n }\n break;\n\n default:\n if (lvl === 0) {\n\n }\n break;\n\n }\n }\n nonAction(i);\n\n if (lvl > 0) {\n var error = "Too many '[' in rule " + inQuotes(tag);\n errors.push(error);\n\n }\n\n if (lvl < 0) {\n var error = "Too many ']' in rule " + inQuotes(tag);\n errors.push(error);\n\n }\n\n return {\n preActions : prefxns,\n postActions : postfxns,\n symbol : symbol,\n mods : mods,\n raw : tag,\n errors : errors,\n };\n};\n\n// Split a rule into sections\nfunction parseRule(rule) {\n var sections = [];\n var errors = [];\n if (!( typeof rule == 'string' || rule instanceof String)) {\n errors.push("Cannot parse non-string rule " + rule);\n sections.errors = errors;\n return sections;\n }\n\n if (rule.length === 0) {\n return [];\n }\n\n var lvl = 0;\n var start = 0;\n var inTag = false;\n\n function createSection(end) {\n var section = rule.substring(start, end);\n if (section.length > 0) {\n if (inTag)\n sections.push(parseTag(section));\n else\n sections.push(section);\n }\n inTag = !inTag;\n start = end + 1;\n\n }\n\n for (var i = 0; i < rule.length; i++) {\n var c = rule.charAt(i);\n\n switch(c) {\n case '[':\n lvl++;\n break;\n case ']':\n lvl--;\n break;\n case '#':\n if (lvl === 0) {\n createSection(i);\n }\n break;\n default:\n break;\n\n }\n\n }\n\n if (lvl > 0) {\n var error = "Too many '[' in rule " + inQuotes(rule);\n errors.push(error);\n\n }\n\n if (lvl < 0) {\n var error = "Too many ']' in rule " + inQuotes(rule);\n errors.push(error);\n\n }\n\n if (inTag) {\n var error = "Odd number of '#' in rule " + inQuotes(rule);\n errors.push(error);\n }\n\n createSection(rule.length);\n sections.errors = errors;\n return sections;\n};\n\nfunction testParse(rule, shouldFail) {\n console.log("-------");\n console.log("Test parse rule: " + inQuotes(rule) + " " + shouldFail);\n var parsed = parseRule(rule);\n if (parsed.errors && parsed.errors.length > 0) {\n for (var i = 0; i < parsed.errors.length; i++) {\n console.log(parsed.errors[i]);\n }\n }\n \n\n}\n\nfunction testParseTag(tag, shouldFail) {\n console.log("-------");\n console.log("Test parse tag: " + inQuotes(tag) + " " + shouldFail);\n var parsed = parseTag(tag);\n if (parsed.errors && parsed.errors.length > 0) {\n for (var i = 0; i < parsed.errors.length; i++) {\n console.log(parsed.errors[i]);\n }\n }\n}\n\ntracery.testParse = testParse;\ntracery.testParseTag = testParseTag;\ntracery.parseRule = parseRule;\ntracery.parseTag = parseTag;\n\n\nfunction spacer(size) {\n var s = "";\n for (var i = 0; i < size * 3; i++) {\n s += " ";\n }\n return s;\n}\n\n/* Simple JavaScript Inheritance\n * By John Resig http://ejohn.org/\n * MIT Licensed.\n */\n\nfunction extend(destination, source) {\n for (var k in source) {\n if (source.hasOwnProperty(k)) {\n destination[k] = source[k];\n }\n }\n return destination;\n}\n\n// Inspired by base2 and Prototype\n(function() {\n var initializing = false,\n fnTest = /xyz/.test(function() { xyz;\n }) ? /\sb_super\sb/ : /.*/;\n\n // The base Class implementation (does nothing)\n this.Class = function() {\n };\n\n // Create a new Class that inherits from this class\n Class.extend = function(prop) {\n var _super = this.prototype;\n\n // Instantiate a base class (but only create the instance,\n // don't run the init constructor)\n initializing = true;\n var prototype = new this();\n initializing = false;\n\n // Copy the properties over onto the new prototype\n for (var name in prop) {\n // Check if we're overwriting an existing function\n prototype[name] = typeof prop[name] == "function" && typeof _super[name] == "function" && fnTest.test(prop[name]) ? (function(name, fn) {\n return function() {\n var tmp = this._super;\n\n // Add a new ._super() method that is the same method\n // but on the super-class\n this._super = _super[name];\n\n // The method only need to be bound temporarily, so we\n // remove it when we're done executing\n var ret = fn.apply(this, arguments);\n this._super = tmp;\n\n return ret;\n };\n })(name, prop[name]) : prop[name];\n }\n\n // The dummy class constructor\n function Class() {\n // All construction is actually done in the init method\n if (!initializing && this.init)\n this.init.apply(this, arguments);\n }\n\n // Populate our constructed prototype object\n Class.prototype = prototype;\n\n // Enforce the constructor to be what we expect\n Class.prototype.constructor = Class;\n\n // And make this class extendable\n Class.extend = arguments.callee;\n\n return Class;\n };\n})();\n\n/**\n * @author Kate\n */\n\nvar Rule = function(raw) {\n this.raw = raw;\n this.sections = parseRule(raw);\n\n};\n\nRule.prototype.getParsed = function() {\n if (!this.sections)\n this.sections = parseRule(raw);\n\n return this.sections;\n};\n\nRule.prototype.toString = function() {\n return this.raw;\n};\n\nRule.prototype.toJSONString = function() {\n return this.raw;\n};\n\n/**\n * @author Kate\n */\n\nvar RuleWeighting = Object.freeze({\n RED : 0,\n GREEN : 1,\n BLUE : 2\n});\n\nvar RuleSet = function(rules) {\n // is the rules obj an array? A RuleSet, or a string?\n if (rules.constructor === Array) {\n // make a copy\n rules = rules.slice(0, rules.length);\n } else if (rules.prototype === RuleSet) {\n // clone\n } else if ( typeof rules == 'string' || rules instanceof String) {\n var args = Array.prototype.slice.call(arguments);\n rules = args;\n } else {\n console.log(rules);\n throw ("creating ruleset with unknown object type!");\n }\n\n // create rules and their use counts\n\n this.rules = rules;\n this.parseAll();\n\n this.uses = [];\n this.startUses = [];\n this.totalUses = 0;\n for (var i = 0; i < this.rules.length; i++) {\n this.uses[i] = 0;\n this.startUses[i] = this.uses[i];\n this.totalUses += this.uses[i];\n }\n\n};\n\n//========================================================\n// Iterating over rules\n\nRuleSet.prototype.parseAll = function(fxn) {\n for (var i = 0; i < this.rules.length; i++) {\n if (this.rules[i].prototype !== Rule)\n this.rules[i] = new Rule(this.rules[i]);\n }\n\n};\n\n//========================================================\n// Iterating over rules\n\nRuleSet.prototype.mapRules = function(fxn) {\n return this.rules.map(function(rule, index) {\n return fxn(rule, index);\n });\n};\n\nRuleSet.prototype.applyToRules = function(fxn) {\n for (var i = 0; i < this.rules.length; i++) {\n fxn(this.rules[i], i);\n }\n};\n//========================================================\nRuleSet.prototype.get = function() {\n var index = this.getIndex();\n\n return this.rules[index];\n};\n\nRuleSet.prototype.getRandomIndex = function() {\n return Math.floor(this.uses.length * Math.random());\n};\n\nRuleSet.prototype.getIndex = function() {\n // Weighted distribution\n // Imagine a bar of length 1, how to divide the length\n // s.t. a random dist will result in the dist we want?\n\n var index = this.getRandomIndex();\n // What if the uses determine the chance of rerolling?\n\n var median = this.totalUses / this.uses.length;\n\n var count = 0;\n while (this.uses[index] > median && count < 20) {\n index = this.getRandomIndex();\n count++;\n }\n\n // reroll more likely if index is too much higher\n\n return index;\n};\n\nRuleSet.prototype.decayUses = function(pct) {\n this.totalUses = 0;\n for (var i = 0; i < this.uses; i++) {\n\n this.uses[index] *= 1 - pct;\n this.totalUses += this.uses[index];\n }\n};\n\nRuleSet.prototype.testRandom = function() {\n console.log("Test random");\n var counts = [];\n for (var i = 0; i < this.uses.length; i++) {\n counts[i] = 0;\n }\n\n var testCount = 10 * this.uses.length;\n for (var i = 0; i < testCount; i++) {\n\n var index = this.getIndex();\n this.uses[index] += 1;\n\n counts[index]++;\n this.decayUses(.1);\n }\n\n for (var i = 0; i < this.uses.length; i++) {\n console.log(i + ":\st" + counts[i] + " \st" + this.uses[i]);\n }\n};\n\nRuleSet.prototype.getSaveRules = function() {\n var jsonRules = this.rules.map(function(rule) {\n return rule.toJSONString();\n });\n\n return jsonRules;\n};\n\n/**\n * @author Kate Compton\n */\n\nvar Action = function(node, raw) {\n\n this.node = node;\n this.grammar = node.grammar;\n this.raw = raw;\n\n};\n\nAction.prototype.activate = function() {\n\n var node = this.node;\n node.actions.push(this);\n\n // replace any hashtags\n this.amended = this.grammar.flatten(this.raw);\n\n var parsed = parseTag(this.amended);\n var subActionRaw = parsed.preActions;\n if (subActionRaw && subActionRaw.length > 0) {\n this.subactions = subActionRaw.map(function(action) {\n return new Action(node, action);\n });\n\n }\n\n if (parsed.symbol) {\n var split = parsed.symbol.split(":");\n\n if (split.length === 2) {\n this.push = {\n symbol : split[0],\n\n // split into multiple rules\n rules : split[1].split(","),\n };\n // push\n node.grammar.pushRules(this.push.symbol, this.push.rules);\n\n } else\n throw ("Unknown action: " + parsed.symbol);\n }\n\n if (this.subactions) {\n for (var i = 0; i < this.subactions.length; i++) {\n this.subactions[i].activate();\n }\n }\n\n};\n\nAction.prototype.deactivate = function() {\n if (this.subactions) {\n for (var i = 0; i < this.subactions.length; i++) {\n this.subactions[i].deactivate();\n }\n }\n\n if (this.push) {\n this.node.grammar.popRules(this.push.symbol, this.push.rules);\n }\n};\n\n/**\n * @author Kate Compton\n */\n\nvar isConsonant = function(c) {\n c = c.toLowerCase();\n switch(c) {\n case 'a':\n return false;\n case 'e':\n return false;\n case 'i':\n return false;\n case 'o':\n return false;\n case 'u':\n return false;\n\n }\n return true;\n};\n\nfunction endsWithConY(s) {\n if (s.charAt(s.length - 1) === 'y') {\n return isConsonant(s.charAt(s.length - 2));\n }\n return false;\n};\n\nvar universalModifiers = {\n capitalizeAll : function(s) {\n return s.replace(/(?:^|\ss)\sS/g, function(a) {\n return a.toUpperCase();\n });\n\n },\n\n capitalize : function(s) {\n return s.charAt(0).toUpperCase() + s.slice(1);\n\n },\n\n inQuotes : function(s) {\n return '"' + s + '"';\n },\n\n comma : function(s) {\n var last = s.charAt(s.length - 1);\n if (last === ",")\n return s;\n if (last === ".")\n return s;\n if (last === "?")\n return s;\n if (last === "!")\n return s;\n return s + ",";\n },\n\n beeSpeak : function(s) {\n // s = s.replace("s", "zzz");\n\n s = s.replace(/s/, 'zzz');\n return s;\n },\n\n a : function(s) {\n if (!isConsonant(s.charAt()))\n return "an " + s;\n return "a " + s;\n\n },\n\n s : function(s) {\n\n var last = s.charAt(s.length - 1);\n\n switch(last) {\n case 'y':\n\n // rays, convoys\n if (!isConsonant(s.charAt(s.length - 2))) {\n return s + "s";\n }\n // harpies, cries\n else {\n return s.slice(0, s.length - 1) + "ies";\n }\n break;\n\n // oxen, boxen, foxen\n case 'x':\n return s.slice(0, s.length - 1) + "en";\n case 'z':\n return s.slice(0, s.length - 1) + "es";\n case 'h':\n return s.slice(0, s.length - 1) + "es";\n\n default:\n return s + "s";\n };\n\n },\n\n ed : function(s) {\n\n var index = s.indexOf(" ");\n var s = s;\n var rest = "";\n if (index > 0) {\n rest = s.substring(index, s.length);\n s = s.substring(0, index);\n\n }\n\n var last = s.charAt(s.length - 1);\n\n switch(last) {\n case 'y':\n\n // rays, convoys\n if (isConsonant(s.charAt(s.length - 2))) {\n return s.slice(0, s.length - 1) + "ied" + rest;\n\n }\n // harpies, cries\n else {\n return s + "ed" + rest;\n }\n break;\n case 'e':\n return s + "d" + rest;\n\n break;\n\n default:\n return s + "ed" + rest;\n };\n }\n};\n/**\n * @author Kate Compton\n */\n\n// A tracery expansion node\nvar nodeCount = 0;\n\nvar ExpansionNode = Class.extend({\n init : function() {\n this.depth = 0;\n this.id = nodeCount;\n nodeCount++;\n this.childText = "[[UNEXPANDED]]";\n },\n\n setParent : function(parent) {\n if (parent) {\n this.depth = parent.depth + 1;\n this.parent = parent;\n this.grammar = parent.grammar;\n }\n },\n\n expand : function() {\n // do nothing\n return "???";\n },\n\n expandChildren : function() {\n\n if (this.children) {\n this.childText = "";\n for (var i = 0; i < this.children.length; i++) {\n this.children[i].expand();\n this.childText += this.children[i].finalText;\n }\n this.finalText = this.childText;\n }\n\n },\n\n createChildrenFromSections : function(sections) {\n var root = this;\n this.children = sections.map(function(section) {\n\n if ( typeof section == 'string' || section instanceof String) {\n // Plaintext\n return new TextNode(root, section);\n } else {\n return new TagNode(root, section);\n }\n });\n }\n});\n\nvar RootNode = ExpansionNode.extend({\n init : function(grammar, rawRule) {\n this._super();\n this.grammar = grammar;\n this.parsedRule = parseRule(rawRule);\n },\n\n expand : function() {\n var root = this;\n this.createChildrenFromSections(this.parsedRule);\n\n // expand the children\n this.expandChildren();\n },\n});\n\nvar TagNode = ExpansionNode.extend({\n init : function(parent, parsedTag) {\n this._super();\n\n if (!(parsedTag !== null && typeof parsedTag === 'object')) {\n if ( typeof parsedTag == 'string' || parsedTag instanceof String) {\n console.warn("Can't make tagNode from unparsed string!");\n parsedTag = parseTag(parsedTag);\n\n } else {\n console.log("Unknown tagNode input: ", parsedTag);\n throw ("Can't make tagNode from strange tag!");\n\n }\n }\n\n this.setParent(parent);\n $.extend(this, parsedTag);\n },\n\n expand : function() {\n if (tracery.outputExpansionTrace)\n console.log(r.sections);\n\n this.rule = this.grammar.getRule(this.symbol);\n\n this.actions = [];\n\n // Parse the rule if it hasn't been already\n this.createChildrenFromSections(this.rule.getParsed());\n\n // Do any pre-expansion actions!\n for (var i = 0; i < this.preActions.length; i++) {\n var action = new Action(this, this.preActions[i]);\n action.activate();\n }\n\n // Map each child section to a node\n if (!this.rule.sections)\n console.log(this.rule);\n\n this.expandChildren();\n\n for (var i = 0; i < this.actions.length; i++) {\n\n this.actions[i].deactivate();\n }\n\n this.finalText = this.childText;\n for (var i = 0; i < this.mods.length; i++) {\n this.finalText = this.grammar.applyMod(this.mods[i], this.finalText);\n }\n\n },\n\n toLabel : function() {\n return this.symbol;\n },\n toString : function() {\n return "TagNode '" + this.symbol + "' mods:" + this.mods + ", preactions:" + this.preActions + ", postactions" + this.postActions;\n }\n});\n\nvar TextNode = ExpansionNode.extend({\n isLeaf : true,\n init : function(parent, text) {\n this._super();\n\n this.setParent(parent);\n\n this.text = text;\n\n this.finalText = text;\n },\n expand : function() {\n // do nothing\n },\n\n toLabel : function() {\n return this.text;\n }\n});\n\n/**\n * @author Kate Compton\n */\n\nfunction Symbol(grammar, key) {\n this.grammar = grammar;\n this.key = key;\n this.currentRules = undefined;\n this.ruleSets = [];\n\n};\n\nSymbol.prototype.loadFrom = function(rules) {\n\n rules = this.wrapRules(rules);\n this.baseRules = rules;\n\n this.ruleSets.push(rules);\n this.currentRules = this.ruleSets[this.ruleSets.length - 1];\n\n};\n\n//========================================================\n// Iterating over rules\n\nSymbol.prototype.mapRules = function(fxn) {\n\n return this.currentRules.mapRules(fxn);\n};\n\nSymbol.prototype.applyToRules = function(fxn) {\n this.currentRules.applyToRules(fxn);\n};\n\n//==================================================\n// Rule pushpops\nSymbol.prototype.wrapRules = function(rules) {\n if (rules.prototype !== RuleSet) {\n if (Array.isArray(rules)) {\n return new RuleSet(rules);\n } else if ( typeof rules == 'string' || rules instanceof String) {\n return new RuleSet(rules);\n } else {\n throw ("Unknown rules type: " + rules);\n }\n }\n // already a ruleset\n return rules;\n};\n\nSymbol.prototype.pushRules = function(rules) {\n rules = this.wrapRules(rules);\n this.ruleSets.push(rules);\n this.currentRules = this.ruleSets[this.ruleSets.length - 1];\n};\n\nSymbol.prototype.popRules = function() {\n var exRules = this.ruleSets.pop();\n\n if (this.ruleSets.length === 0) {\n //console.warn("No more rules for " + this + "!");\n }\n this.currentRules = this.ruleSets[this.ruleSets.length - 1];\n};\n\n// Clear everything and set the rules\nSymbol.prototype.setRules = function(rules) {\n\n rules = this.wrapRules(rules);\n this.ruleSets = [rules];\n this.currentRules = rules;\n\n};\n\nSymbol.prototype.addRule = function(rule) {\n this.currentRules.addRule(seed);\n};\n\n//========================================================\n// selection\n\nSymbol.prototype.select = function() {\n this.isSelected = true;\n\n};\n\nSymbol.prototype.deselect = function() {\n this.isSelected = false;\n};\n\n//==================================================\n// Getters\n\nSymbol.prototype.getRule = function(seed) {\n return this.currentRules.get(seed);\n};\n\n//==================================================\n\nSymbol.prototype.toString = function() {\n return this.key + ": " + this.currentRules + "(overlaying " + (this.ruleSets.length - 1) + ")";\n};\nSymbol.prototype.toJSON = function() {\n\n var rules = this.baseRules.rules.map(function(rule) {\n return '"' + rule.raw + '"';\n });\n return '"' + this.key + '"' + ": [" + rules.join(", ") + "]";\n};\n\nSymbol.prototype.toHTML = function(useSpans) {\n var keySpan = '"' + this.key + '"';\n if (useSpans)\n keySpan = "<span class='symbol symbol_" + this.key + "'>" + keySpan + "</span>";\n\n var rules = this.baseRules.rules.map(function(rule) {\n var s = '"' + rule.raw + '"';\n if (useSpans)\n s = "<span class='rule'>" + s + "</span>";\n return s;\n });\n return keySpan + ": [" + rules.join(", ") + "]";\n};\n\n/**\n * @author Kate Compton\n */\n\nfunction Grammar() {\n this.clear();\n};\n\nGrammar.prototype.clear = function() {\n // Symbol library\n this.symbols = {};\n \n this.errors = [];\n \n // Modifier library\n this.modifiers = {};\n\n // add the universal mods\n for (var mod in universalModifiers) {\n if (universalModifiers.hasOwnProperty(mod))\n this.modifiers[mod] = universalModifiers[mod];\n }\n};\n//========================================================\n// Loading\n\nGrammar.prototype.loadFrom = function(obj) {\n var symbolSrc;\n\n this.clear();\n\n if (obj.symbols !== undefined) {\n symbolSrc = obj.symbols;\n } else {\n symbolSrc = obj;\n }\n\n // get all json keys\n var keys = Object.keys(symbolSrc);\n\n this.symbolNames = [];\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n this.symbolNames.push(key);\n\n this.symbols[key] = new Symbol(this, key);\n this.symbols[key].loadFrom(symbolSrc[key]);\n }\n\n};\n\nGrammar.prototype.toHTML = function(useSpans) {\n // get all json keys\n var keys = Object.keys(this.symbols);\n\n this.symbolNames = [];\n\n var lines = [];\n\n var count = 0;\n for (var i = 0; i < keys.length; i++) {\n\n var key = keys[i];\n var symbol = this.symbols[key];\n\n if (symbol && symbol.baseRules) {\n\n lines.push(" " + this.symbols[key].toHTML(useSpans));\n\n }\n };\n\n var s;\n s = lines.join(",</p><p>");\n s = "{<p>" + s + "</p>}";\n return s;\n};\n\nGrammar.prototype.toJSON = function() {\n // get all json keys\n var keys = Object.keys(this.symbols);\n\n this.symbolNames = [];\n\n var lines = [];\n\n var count = 0;\n for (var i = 0; i < keys.length; i++) {\n\n var key = keys[i];\n var symbol = this.symbols[key];\n\n if (symbol && symbol.baseRules) {\n\n lines.push(" " + this.symbols[key].toJSON());\n\n }\n };\n\n var s;\n s = lines.join(",\sn");\n s = "{\sn" + s + "\sn}";\n return s;\n};\n\n//========================================================\n// selection\n\nGrammar.prototype.select = function() {\n this.isSelected = true;\n};\n\nGrammar.prototype.deselect = function() {\n this.isSelected = false;\n};\n\n//========================================================\n// Iterating over symbols\n\nGrammar.prototype.mapSymbols = function(fxn) {\n var symbols = this.symbols;\n return this.symbolNames.map(function(name) {\n return fxn(symbols[name], name);\n });\n};\n\nGrammar.prototype.applyToSymbols = function(fxn) {\n for (var i = 0; i < this.symbolNames.length; i++) {\n var key = this.symbolNames[i];\n fxn(this.symbols[key], key);\n }\n};\n\n//========================================================\nGrammar.prototype.addOrGetSymbol = function(key) {\n if (this.symbols[key] === undefined)\n this.symbols[key] = new Symbol(key);\n\n return this.symbols[key];\n};\n\nGrammar.prototype.pushRules = function(key, rules) {\n var symbol = this.addOrGetSymbol(key);\n symbol.pushRules(rules);\n};\n\nGrammar.prototype.popRules = function(key, rules) {\n var symbol = this.addOrGetSymbol(key);\n var popped = symbol.popRules();\n\n if (symbol.ruleSets.length === 0) {\n // remove symbol\n this.symbols[key] = undefined;\n }\n};\n\nGrammar.prototype.applyMod = function(modName, text) {\n if (!this.modifiers[modName]) {\n console.log(this.modifiers);\n throw ("Unknown mod: " + modName);\n }\n return this.modifiers[modName](text);\n};\n\n//============================================================\nGrammar.prototype.getRule = function(key, seed) {\n var symbol = this.symbols[key];\n if (symbol === undefined) {\n var r = new Rule("{{" + key + "}}");\n\n r.error = "Missing symbol " + key;\n return r;\n }\n\n var rule = symbol.getRule();\n if (rule === undefined) {\n var r = new Rule("[" + key + "]");\n console.log(r.sections);\n r.error = "Symbol " + key + " has no rule";\n return r;\n }\n\n return rule;\n};\n\n//============================================================\n// Expansions\nGrammar.prototype.expand = function(raw) {\n\n // Start a new tree\n var root = new RootNode(this, raw);\n\n root.expand();\n\n return root;\n};\n\nGrammar.prototype.flatten = function(raw) {\n\n // Start a new tree\n var root = new RootNode(this, raw);\n\n root.expand();\n\n return root.childText;\n};\n\n//===============\n\nGrammar.prototype.analyze = function() {\n this.symbolNames = [];\n for (var name in this.symbols) {\n if (this.symbols.hasOwnProperty(name)) {\n this.symbolNames.push(name);\n }\n }\n\n // parse every rule\n\n for (var i = 0; i < this.symbolNames.length; i++) {\n var key = this.symbolNames[i];\n var symbol = this.symbols[key];\n // parse all\n for (var j = 0; j < symbol.baseRules.length; j++) {\n var rule = symbol.baseRules[j];\n rule.parsed = tracery.parse(rule.raw);\n // console.log(rule);\n\n }\n }\n\n};\n\nGrammar.prototype.selectSymbol = function(key) {\n console.log(this);\n var symbol = this.get(key);\n};\n/**\n * @author Kate Compton\n\n */\n\ntracery.createGrammar = function(obj) {\n var grammar = new Grammar();\n grammar.loadFrom(obj);\n return grammar;\n};\n\ntracery.test = function() {\n\n console.log("==========================================");\n console.log("test tracery");\n\n // good\n tracery.testParse("", false);\n tracery.testParse("fooo", false);\n tracery.testParse("####", false);\n tracery.testParse("#[]#[]##", false);\n tracery.testParse("#someSymbol# and #someOtherSymbol#", false);\n tracery.testParse("#someOtherSymbol.cap.pluralize#", false);\n tracery.testParse("#[#do some things#]symbol.mod[someotherthings[and a function]]#", false);\n tracery.testParse("#[fxn][fxn][fxn[subfxn]]symbol[[fxn]]#", false);\n tracery.testParse("#[fxn][#fxn#][fxn[#subfxn#]]symbol[[fxn]]#", false);\n tracery.testParse("#hero# ate some #color# #animal.s#", false);\n tracery.testParseTag("[action]symbol.mod1.mod2[postAction]", false);\n\n // bad\n tracery.testParse("#someSymbol# and #someOtherSymbol", true);\n tracery.testParse("#[fxn][fxn][fxn[subfxn]]symbol[fxn]]#", true);\n\n // bad\n tracery.testParseTag("stuff[action]symbol.mod1.mod2[postAction]", true);\n tracery.testParseTag("[action]symbol.mod1.mod2[postAction]stuff", true);\n\n tracery.testParse("#hero# ate some #color# #animal.s#", true);\n tracery.testParse("#[#setPronouns#][#setOccupation#][hero:#name#]story#", true);\n\n};\n \n})();
jquery:on\nhash:off\nbookmark:on\nmodernizr:off\nundo:on\nobfuscate:off\nexitprompt:off\nblankcss:off\n
<<silently>>\nUses the parameter if one was passed. Then, checks for the $symbol variable. If neither is present, uses "origin". Clears $symbol at the end.\n\n<<if parameter(0)>>\n\t<<set $symbol to parameter(0)>>\n<<else>><<if $symbol>>\n\tNo need to do anything.\n<<else>>\n\t<<set $symbol to "origin">>\n<<endif>><<endif>>\n\n<<endsilently>><<print console.log("trace " + $symbol)>><<print tale.grammar.flatten("#" + $symbol + "#")>><<forget $symbol>>
// Returns an array of traces, each different from the one preceding it unless retrace() maxes out attempts.\n\nwindow.traceArray = function(symbol, num){\n\tvar output = [];\n\toutput.push( trace(symbol) );\n\n\tfor (var i = 1; i < num; i++) {\n\t\toutput.push( retrace(symbol, output[i-1]) );\n\t};\n\n\treturn output;\n}
<<twineceryInit>>\n<<traceryInit>>
String.prototype.contains = function(substring){\n\tif (substring.constructor === Array){\n\t\tfor (var i = 0; i < substring.length; i++){\n\t\t\tif(this.contains(substring[i])){\n\t\t\t\treturn substring[i]; // Non-empty string evaluates to true\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t} else {\n\t\treturn this.indexOf(substring) > 0;\n\t}\n}
// Returns a new version of a given expansion.\nwindow.retrace = function(symbol, old, maxAttempts){\n\tif(maxAttempts === undefined){\n\t\tmaxAttempts = 32;\n\t}\n\tif(!(maxAttempts > 1)){\n\t\tmaxAttempts = 1;\n\t}\n\t\n\tvar output = "", attempts = 0;\n\tdo{\n\t\toutput = trace(symbol);\n\t\tattempts++;\n\t}while(output == old && attempts < maxAttempts)\n\n//\tconsole.log("retrace:"\n//\t\t\t\t+ "\sn\stold: " + old\n//\t\t\t\t+ "\sn\stnew: " + output\n//\t\t\t\t+ "\sn\stattempts: " + attempts)\n\treturn output;\n}
<<tracelink "origin">>\n
body {\n margin: 2%;\n}\n#passages{\n margin: 0;\n padding: 0;\n border: 0;\n width:96%;\n margin: auto;\n}\n.passage {\n font-size:6em; \n color: #888;\n text-shadow: #888 0 0 0.05em;\n}\n@media screen and (max-width: 960px) {\n .passage {\n font-size: 4em;\n }\n}\n@media screen and (max-width: 640px) {\n .passage {\n font-size: 3em;\n }\n}\na.internalLink, a.externalLink {\n color: #eee;\n text-shadow: #eee 0 0 0.07em;\n}\na.internalLink:hover, a.externalLink:hover {\n color: #fff;\n text-decoration: none;\n text-shadow: #fff 0 0 0.09em;\n}\n#sidebar {\n\tdisplay:none;\n}\nbody\n{\n background-color: #145A32;\n}
window.grammar = function(rule){\n\treturn tale.get(rule).text.split('\sn');\n}
// Expands a symbol and returns the output.\nwindow.trace = function(symbol){\n\tif(symbol === undefined){\n\t\tsymbol = "origin";\n\t}\n\tif(tale.grammar === undefined){\n\t\tconsole.log("Couldn't find the grammar object.");\n\t\treturn "ERROR: Grammar object not found.";\n\t}\n\n\tvar output = tale.grammar.flatten("#" + symbol + "#")\t\n//\tconsole.log(symbol + " expands to:\sn" + output);\n\treturn output;\n}
// This is a slightly modified version of Leon Arnott's cyclinglink macro.\n\nversion.extensions.tracelinkMacro = {\n\tmajor: 0,\n\tminor: 1,\n\trevision: 0\n};\nmacros.tracelink = {\n\thandler: function(a, b, c) {\n\t\tvar rl = "traceLink";\n\n\t\tfunction toggleText(w) {\n\t\t\tw.classList.remove("traceLinkInit");\n\t\t\tw.classList.toggle(rl + "Enabled");\n\t\t\tw.classList.toggle(rl + "Disabled");\n\t\t\tw.style.display = ((w.style.display == "none") ? "inline" : "none")\n\t\t}\n\t\tswitch (c[c.length - 1]) {\n\t\t\tcase "end":\n\t\t\t\tvar end = true;\n\t\t\t\tc.pop();\n\t\t\t\tbreak;\n\t\t\tcase "out":\n\t\t\t\tvar out = true;\n\t\t\t\tc.pop();\n\t\t\t\tbreak\n\t\t}\n\t\tvar v = "";\n\t\tif (c.length && c[0][0] == "$") {\n\t\t\tv = c[0].slice(1);\n\t\t\tc.shift()\n\t\t}\n\t\tvar h = state.history[0].variables;\n\t\tif (out && h[v] === "") {\n\t\t\treturn\n\t\t}\n\t\tvar l = Wikifier.createInternalLink(a, null);\n\t\tl.className = "internalLink cyclingLink";\n\t\tl.setAttribute("data-cycle", 0);\n\n\t\t// Prebake a bunch of traces and use those as our links to cycle through.\n\t\tc = traceArray(c[0], 64);\n\n\t\tfor (var i = 0; i < c.length; i++) {\n\t\t\tvar on = (i == Math.max(c.indexOf(h[v]), 0));\n\t\t\tvar d = insertElement(null, "span", null, "traceLinkInit traceLink" + ((on) ? "En" : "Dis") + "abled");\n\t\t\tif (on) {\n\t\t\t\th[v] = c[i];\n\t\t\t\tl.setAttribute("data-cycle", i)\n\t\t\t} else {\n\t\t\t\td.style.display = "none"\n\t\t\t}\n\t\t\tinsertText(d, c[i]);\n\t\t\tif (on && end && i == c.length - 1) {\n\t\t\t\tl.parentNode.replaceChild(d, l)\n\t\t\t} else {\n\t\t\t\tl.appendChild(d)\n\t\t\t}\n\t\t}\n\t\tl.onclick = function() {\n\t\t\tvar t = this.childNodes;\n\t\t\tvar u = this.getAttribute("data-cycle") - 0;\n\t\t\tvar m = t.length;\n\t\t\ttoggleText(t[u]);\n\t\t\tu = (u + 1);\n\t\t\tif (!(out && u == m)) {\n\t\t\t\tu %= m;\n\t\t\t\tif (v) {\n\t\t\t\t\th[v] = c[u]\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\th[v] = ""\n\t\t\t}\n\t\t\tif ((end || out) && u == m - (end ? 1 : 0)) {\n\t\t\t\tif (end) {\n\t\t\t\t\tvar n = this.removeChild(t[u]);\n\t\t\t\t\tn.className = rl + "End";\n\t\t\t\t\tn.style.display = "inline";\n\t\t\t\t\tthis.parentNode.replaceChild(n, this)\n\t\t\t\t} else {\n\t\t\t\t\tthis.parentNode.removeChild(this);\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\t\t\ttoggleText(t[u]);\n\t\t\tthis.setAttribute("data-cycle", u)\n\t\t}\n\t}\n};
Weed Strain Generator
Nora Reed with Tracery/Twine help from Vin Tanner
<<if !tale.grammar>>\n\t<<if tracery>>\n\t\t<<set tale.grammar = tracery.createGrammar(tale.story.data)>>\n\t\t<<print console.log("grammar: ", tale.grammar)>>\n\t<<else>>\n\t\t<<print console.log("grammar instantiation failed")>>\n\t<<endif>>\n<<endif>>