title
7.2: Context-Free Grammar with Tracery - Programming with Text
description
In this video, I demonstrate how to use Kate Compton's Tracery library to generate a story from a set of grammar rules.. This video is part of Session 7 of the "Programming from A to Z" ITP class.
Links mentioned in this video:
🔗Tracery: https://github.com/galaxykate/tracery
🔗Kate Compton: https://twitter.com/GalaxyKate
🔗Next video: https://youtu.be/VaAoIaZ3YKs
🔗Course url: http://shiffman.net/a2z/
🚂Website: https://thecodingtrain.com/
💡Github: https://github.com/CodingTrain
💬Discord: https://discord.gg/hPuGy2g
💖Membership: https://youtube.com/thecodingtrain/join
🛒Store: https://standard.tv/collections/the-coding-train
📚Books: https://www.amazon.com/shop/thecodingtrain
🖋️Twitter: https://twitter.com/thecodingtrain
🎥 More Perlin Noise: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6bgPNQAdxQZpJuJCjeOr7VD
🎥Coding Challenges: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
🎥Intro to Programming using p5.js: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA
📄 Code of Conduct: https://github.com/CodingTrain/Code-of-Conduct
🌐Help us caption and translate: http://www.youtube.com/timedtext_cs_panel?c=UCvjgXvBlbQiydffZU7m1_aw&tab=2
🚩Suggest Topics: https://github.com/CodingTrain/Rainbow-Topics
👾Share your contribution: https://thecodingtrain.com/Guides/community-contribution-guide.html
🔗 p5.js: https://p5js.org
🔗 Processing: https://processing.org
detail
{'title': '7.2: Context-Free Grammar with Tracery - Programming with Text', 'heatmap': [], 'summary': 'Discusses tracery, a javascript library for text generation, showcasing its use for creating stories, generating text with color and emojis, and using production rules. it also demonstrates creating grammar using tracery and jquery for narrative scenarios and haiku patterns, and explores the library features including multiple possibilities and collaborative grammar creation.', 'chapters': [{'end': 245.125, 'segs': [{'end': 45.565, 'src': 'embed', 'start': 0.598, 'weight': 0, 'content': [{'end': 2.72, 'text': 'Hello Welcome to another video tutorial.', 'start': 0.598, 'duration': 2.122}, {'end': 5.963, 'text': 'This is part of session seven, programming from A to Z.', 'start': 2.76, 'duration': 3.203}, {'end': 10.887, 'text': 'And all these videos are about grammar, specifically context-free grammars.', 'start': 5.963, 'duration': 4.924}, {'end': 17.873, 'text': 'So today I want to talk about a particular grammar generation library for JavaScript called tracery.', 'start': 11.147, 'duration': 6.726}, {'end': 22.515, 'text': 'Tracery is by Kate Compton, at galaxykate on GitHub.', 'start': 18.493, 'duration': 4.022}, {'end': 24.156, 'text': "It's a wonderful project.", 'start': 22.735, 'duration': 1.421}, {'end': 28.958, 'text': 'It allows you to be really creative with generating text, generating stories,', 'start': 24.216, 'duration': 4.742}, {'end': 35.06, 'text': 'making a Twitter bot just by putting together a bunch of possibilities in a way, a grammar, so to speak.', 'start': 28.958, 'duration': 6.102}, {'end': 37.021, 'text': "So first I'm going to show you an example.", 'start': 35.34, 'duration': 1.681}, {'end': 41.123, 'text': 'This is actually called Once Upon a Time Stories.', 'start': 37.621, 'duration': 3.502}, {'end': 44.484, 'text': 'It is by a five-year-old and an eight-year-old who happen to be related to me.', 'start': 41.503, 'duration': 2.981}, {'end': 45.565, 'text': "They're my children.", 'start': 44.885, 'duration': 0.68}], 'summary': 'Introduction to tracery, a javascript grammar generation library for creative text and story generation.', 'duration': 44.967, 'max_score': 0.598, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C3EwsSNJeOE/pics/C3EwsSNJeOE598.jpg'}, {'end': 106.041, 'src': 'embed', 'start': 81.114, 'weight': 3, 'content': [{'end': 89.378, 'text': "this is one way of using a grammar like tracery to generate and there's a little bit of like color and emojis and stuff going on here but to generate text.", 'start': 81.114, 'duration': 8.264}, {'end': 95.881, 'text': 'So let me just look into the code for this for a second, so that I can point out to you what the grammar actually.', 'start': 89.398, 'duration': 6.483}, {'end': 99.202, 'text': "oops, I'm in the wrong place, what the grammar actually looks like.", 'start': 95.881, 'duration': 3.321}, {'end': 102.438, 'text': 'So this is what the grammar actually looks like.', 'start': 100.697, 'duration': 1.741}, {'end': 106.041, 'text': 'And the grammar is simply a JavaScript object.', 'start': 102.839, 'duration': 3.202}], 'summary': 'Using tracery grammar to generate text with javascript object.', 'duration': 24.927, 'max_score': 81.114, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C3EwsSNJeOE/pics/C3EwsSNJeOE81114.jpg'}, {'end': 165.507, 'src': 'embed', 'start': 137.137, 'weight': 2, 'content': [{'end': 143.099, 'text': 'In JavaScript, if you want to have emojis, You can just stick emojis in there, read just as text like anything else.', 'start': 137.137, 'duration': 5.962}, {'end': 147.62, 'text': "I mean, how they're interpreted and displayed depends on what the environment you're living in.", 'start': 143.139, 'duration': 4.481}, {'end': 153.102, 'text': 'But the characters themselves are there for you to use.', 'start': 147.68, 'duration': 5.422}, {'end': 158.763, 'text': "OK, so let's make our own tracery grammar.", 'start': 153.282, 'duration': 5.481}, {'end': 160.464, 'text': "And then we'll come back to this one.", 'start': 159.063, 'duration': 1.401}, {'end': 165.507, 'text': 'OK, so what am I doing here? I want to go to my example, which is over here.', 'start': 161.124, 'duration': 4.383}], 'summary': 'Javascript allows emojis as text, their interpretation depends on the environment.', 'duration': 28.37, 'max_score': 137.137, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C3EwsSNJeOE/pics/C3EwsSNJeOE137137.jpg'}, {'end': 245.125, 'src': 'embed', 'start': 205.794, 'weight': 4, 'content': [{'end': 210.675, 'text': 'Now, another thing, actually, by the way, is tracery is dependent on jQuery.', 'start': 205.794, 'duration': 4.881}, {'end': 212.475, 'text': 'So it uses jQuery behind the scenes.', 'start': 210.735, 'duration': 1.74}, {'end': 216.616, 'text': 'So I also should make sure I download and grab jQuery.', 'start': 212.915, 'duration': 3.701}, {'end': 219.436, 'text': 'So I also have a reference to jQuery here.', 'start': 217.196, 'duration': 2.24}, {'end': 224.597, 'text': "One thing I'll note, by the way, is that you can reference JavaScript libraries either as local files like.", 'start': 219.516, 'duration': 5.081}, {'end': 229.078, 'text': 'I have a local copy of p5.dom.js here in my folder.', 'start': 224.597, 'duration': 4.481}, {'end': 233.739, 'text': 'But you can also reference libraries through something called a CDN, or Content Delivery Network.', 'start': 229.338, 'duration': 4.401}, {'end': 237.661, 'text': "Meaning if it's a really popular library, somebody might have just hosted it somewhere.", 'start': 234.099, 'duration': 3.562}, {'end': 240.323, 'text': 'And instead of having to download it, I could just reference the URL.', 'start': 237.681, 'duration': 2.642}, {'end': 242.644, 'text': "And there's good reasons for doing one or the other.", 'start': 240.383, 'duration': 2.261}, {'end': 243.905, 'text': "And I'm kind of mixing and matching here.", 'start': 242.684, 'duration': 1.221}, {'end': 245.125, 'text': 'But I just want to get stuff working.', 'start': 243.945, 'duration': 1.18}], 'summary': 'Tracery uses jquery, can be referenced via local files or cdn, aiming to get stuff working.', 'duration': 39.331, 'max_score': 205.794, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C3EwsSNJeOE/pics/C3EwsSNJeOE205794.jpg'}], 'start': 0.598, 'title': 'Tracery: creative text generation in javascript', 'summary': 'Discusses tracery, a javascript library for generating stories using context-free grammars, showcasing the process and quantifying the possibilities. it also explores the use of tracery to generate text with color, emojis, and production rules, emphasizing the setup process and dependency on jquery.', 'chapters': [{'end': 81.114, 'start': 0.598, 'title': 'Tracery: creative text generation in javascript', 'summary': 'Discusses tracery, a javascript library for creative text generation, particularly generating stories, using context-free grammars, with an example of generating stories and quantifying the possibilities.', 'duration': 80.516, 'highlights': ['The tracery library for JavaScript, developed by Kate Compton, enables creative text generation using context-free grammars, allowing for the generation of stories, and even the creation of a Twitter bot.', 'An example of text generation using tracery is showcased, featuring stories created by a five-year-old and an eight-year-old, demonstrating the flexibility and creative potential of tracery for generating narratives.']}, {'end': 245.125, 'start': 81.114, 'title': 'Using tracery to generate text', 'summary': 'Explores the use of tracery, a javascript library, to generate text with the incorporation of color, emojis, and production rules, while also highlighting the process of setting up the tracery library and its dependency on jquery.', 'duration': 164.011, 'highlights': ['The chapter demonstrates the use of tracery, a JavaScript library, to generate text with the incorporation of color and emojis.', 'It explains the concept of production rules in the context of tracery, emphasizing the process of replacing specific elements with others.', 'The transcript details the setup process for the tracery library, including the steps to obtain and reference the tracery.js file and its dependency on jQuery.', 'It discusses the option to reference JavaScript libraries through a Content Delivery Network (CDN) or as local files, offering flexibility in the implementation of libraries.']}], 'duration': 244.527, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C3EwsSNJeOE/pics/C3EwsSNJeOE598.jpg', 'highlights': ['The tracery library for JavaScript enables creative text generation using context-free grammars, allowing for the generation of stories and even the creation of a Twitter bot.', 'An example of text generation using tracery is showcased, featuring stories created by a five-year-old and an eight-year-old, demonstrating the flexibility and creative potential of tracery for generating narratives.', 'The chapter demonstrates the use of tracery, a JavaScript library, to generate text with the incorporation of color and emojis.', 'It explains the concept of production rules in the context of tracery, emphasizing the process of replacing specific elements with others.', 'The transcript details the setup process for the tracery library, including the steps to obtain and reference the tracery.js file and its dependency on jQuery.', 'It discusses the option to reference JavaScript libraries through a Content Delivery Network (CDN) or as local files, offering flexibility in the implementation of libraries.']}, {'end': 472.43, 'segs': [{'end': 399.946, 'src': 'embed', 'start': 266.787, 'weight': 0, 'content': [{'end': 269.208, 'text': "So I'm going to make a variable called, and let's make it a story.", 'start': 266.787, 'duration': 2.421}, {'end': 276.991, 'text': 'And what I need is to have, now, tracery by default looks for something called start.', 'start': 271.649, 'duration': 5.342}, {'end': 280.792, 'text': "So you don't have to name it start, but I'm going to call it start.", 'start': 277.871, 'duration': 2.921}, {'end': 287.315, 'text': "And I'm going to say start is, and I'm going to need the chat, by the way, to start giving me ideas for story things.", 'start': 281.192, 'duration': 6.123}, {'end': 289.576, 'text': "But I guess I'll just be making this up as I go right now.", 'start': 287.355, 'duration': 2.221}, {'end': 292.557, 'text': 'It was a dark and stormy day.', 'start': 290.516, 'duration': 2.041}, {'end': 302.707, 'text': 'night So now, if I have this JavaScript object, which essentially holds the grammar, I should be able to make a variable called grammar.', 'start': 293.723, 'duration': 8.984}, {'end': 304.988, 'text': 'Oops, I misspelled grammar.', 'start': 302.727, 'duration': 2.261}, {'end': 308.489, 'text': "AR OK, so I'm going to have a variable called grammar.", 'start': 305.088, 'duration': 3.401}, {'end': 315.753, 'text': "And I'm going to say grammar equals tracery dot, I think, create grammar.", 'start': 310.13, 'duration': 5.623}, {'end': 319.577, 'text': "Boy, I don't actually remember if that's correct.", 'start': 317.855, 'duration': 1.722}, {'end': 323.061, 'text': "So one of the things when you're working with the JavaScript library is you've got to look at documentation.", 'start': 319.817, 'duration': 3.244}, {'end': 334.034, 'text': "So I'm going to just go back to the GitHub page for tracery, and just to kind of remind myself, yes, tracery.creategrammar spellbook.", 'start': 323.381, 'duration': 10.653}, {'end': 334.615, 'text': 'By the way,', 'start': 334.195, 'duration': 0.42}, {'end': 342.56, 'text': "If you're looking for an idea certain things like a cooking recipe or a spell book there's a wonderful Twitter bot called ArtAssignmentBot.", 'start': 335.396, 'duration': 7.164}, {'end': 350.845, 'text': "I don't know that it uses a grammar, but these kinds of highly structured types of narrative scenarios can work really well.", 'start': 342.6, 'duration': 8.245}, {'end': 353.527, 'text': 'to have a grammar generate different possibilities.', 'start': 350.845, 'duration': 2.682}, {'end': 359.882, 'text': "I'll also show you at some point that you can use a grammar to generate haiku patterns or certain patterns or certain syllables.", 'start': 354.318, 'duration': 5.564}, {'end': 361.743, 'text': "It's another way to use a grammar.", 'start': 359.902, 'duration': 1.841}, {'end': 364.885, 'text': 'OK So tracery.createGrammarStory.', 'start': 361.843, 'duration': 3.042}, {'end': 367.607, 'text': 'Perfect So now I want to look at the result.', 'start': 364.925, 'duration': 2.682}, {'end': 372.19, 'text': "And I'll say var result equals grammar.flatten.", 'start': 367.647, 'duration': 4.543}, {'end': 379.728, 'text': "So again, why the word flatten? So there's two words that involve generating text from a grammar.", 'start': 374.963, 'duration': 4.765}, {'end': 382.231, 'text': 'One is expansion and the other is flatten.', 'start': 379.848, 'duration': 2.383}, {'end': 383.853, 'text': 'So this is the idea of an.', 'start': 382.611, 'duration': 1.242}, {'end': 384.353, 'text': 'where am I here?', 'start': 383.853, 'duration': 0.5}, {'end': 385.955, 'text': 'This is the idea of an expansion, right?', 'start': 384.373, 'duration': 1.582}, {'end': 391.902, 'text': "I'm expanding out from the sort of start and iteratively applying these replacement rules.", 'start': 386.276, 'duration': 5.626}, {'end': 398.145, 'text': "Now, tracery behind the scenes or any grammar system is probably keeping track of the entire tree that's being generated.", 'start': 392.242, 'duration': 5.903}, {'end': 399.946, 'text': 'But all I want is the end result.', 'start': 398.405, 'duration': 1.541}], 'summary': 'Creating a story using tracery.js to generate text from a grammar, aiming to get different possibilities and patterns.', 'duration': 133.159, 'max_score': 266.787, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C3EwsSNJeOE/pics/C3EwsSNJeOE266787.jpg'}, {'end': 463.416, 'src': 'embed', 'start': 430.556, 'weight': 2, 'content': [{'end': 433.217, 'text': 'I want to pass that to the grammar and the grammar.', 'start': 430.556, 'duration': 2.661}, {'end': 438.779, 'text': 'the grammar object, the tracer grammar object, is then going to expand it out based on all those production rules.', 'start': 433.217, 'duration': 5.562}, {'end': 450.467, 'text': "now, right now, and You'll notice that the syntax for tracery, specifically, is a non-terminal element is wrapped in the pound or hash symbol.", 'start': 438.779, 'duration': 11.688}, {'end': 454.009, 'text': 'So this means please replace me as opposed to the word start.', 'start': 450.667, 'duration': 3.342}, {'end': 463.416, 'text': 'And so if I did something like this we would have a real problem because this would kind of generate to infinity.', 'start': 455.37, 'duration': 8.046}], 'summary': 'Tracer grammar expands input based on production rules for tracery syntax.', 'duration': 32.86, 'max_score': 430.556, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C3EwsSNJeOE/pics/C3EwsSNJeOE430556.jpg'}], 'start': 245.466, 'title': 'Using tracery and jquery for grammar creation and text generation', 'summary': 'Demonstrates creating a grammar using tracery and jquery in javascript, and discusses using grammar for narrative scenarios, haiku patterns, and expansion and flattening in grammar generation.', 'chapters': [{'end': 334.615, 'start': 245.466, 'title': 'Using tracery and jquery for grammar creation', 'summary': 'Demonstrates the process of creating a grammar using the tracery and jquery libraries in javascript, including defining variables, setting up the grammar, and referencing documentation.', 'duration': 89.149, 'highlights': ["The process involves setting up a variable called 'story' and initializing the grammar with a default start point.", 'The speaker looks for input from the chat to generate ideas for the story.', "A JavaScript object is used to hold the grammar, and a variable 'grammar' is created using the tracery library.", 'Referencing documentation is highlighted as an important step when working with the JavaScript library.']}, {'end': 472.43, 'start': 335.396, 'title': 'Using grammar to generate text', 'summary': 'Discusses using grammar to generate text, including examples of using grammar for narrative scenarios, haiku patterns, and the concept of expansion and flattening in grammar generation.', 'duration': 137.034, 'highlights': ['The chapter discusses using grammar to generate text, including examples of using grammar for narrative scenarios, haiku patterns, and the concept of expansion and flattening in grammar generation.', 'The Twitter bot called ArtAssignmentBot is mentioned as a tool for generating ideas like cooking recipes or spell books.', 'Explains the use of grammar to generate haiku patterns or certain syllables as another method of utilizing grammar for text generation.', "The concept of expansion and flattening in grammar generation is explained, with 'flatten' being used to obtain the end result of the generated text.", "Tracery's syntax for non-terminal elements is highlighted, using the pound or hash symbol to indicate replacement in the grammar.", "The importance of providing a seed phrase, such as 'start,' to the grammar for expanding it based on production rules is emphasized."]}], 'duration': 226.964, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C3EwsSNJeOE/pics/C3EwsSNJeOE245466.jpg', 'highlights': ['The chapter discusses using grammar to generate text, including examples of using grammar for narrative scenarios, haiku patterns, and the concept of expansion and flattening in grammar generation.', "The concept of expansion and flattening in grammar generation is explained, with 'flatten' being used to obtain the end result of the generated text.", "The importance of providing a seed phrase, such as 'start,' to the grammar for expanding it based on production rules is emphasized.", "Tracery's syntax for non-terminal elements is highlighted, using the pound or hash symbol to indicate replacement in the grammar.", "The process involves setting up a variable called 'story' and initializing the grammar with a default start point.", "A JavaScript object is used to hold the grammar, and a variable 'grammar' is created using the tracery library.", 'The speaker looks for input from the chat to generate ideas for the story.', 'Referencing documentation is highlighted as an important step when working with the JavaScript library.', 'The Twitter bot called ArtAssignmentBot is mentioned as a tool for generating ideas like cooking recipes or spell books.', 'Explains the use of grammar to generate haiku patterns or certain syllables as another method of utilizing grammar for text generation.']}, {'end': 987.502, 'segs': [{'end': 697.168, 'src': 'embed', 'start': 672.523, 'weight': 0, 'content': [{'end': 679.867, 'text': 'So one of the wonderful things that tracery has is it has a mechanism for you to assign a production rule.', 'start': 672.523, 'duration': 7.344}, {'end': 686.71, 'text': "essentially, almost have a variable that holds something that's picked in the grammar over time across the entire sentence,", 'start': 679.867, 'duration': 6.843}, {'end': 687.89, 'text': "the story that's being generated.", 'start': 686.71, 'duration': 1.18}, {'end': 691.231, 'text': 'So in that sense, what I can do here is I want to start with start.', 'start': 688.25, 'duration': 2.981}, {'end': 697.168, 'text': 'And what I want start to render, so to speak, to expand is the story.', 'start': 692.867, 'duration': 4.301}], 'summary': 'Tracery allows assigning production rules, like using a variable to pick grammar elements over time in sentence generation.', 'duration': 24.645, 'max_score': 672.523, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C3EwsSNJeOE/pics/C3EwsSNJeOE672523.jpg'}, {'end': 797.461, 'src': 'embed', 'start': 769.17, 'weight': 2, 'content': [{'end': 771.47, 'text': 'Because really the creativity now lies in.', 'start': 769.17, 'duration': 2.3}, {'end': 772.751, 'text': 'how far can you go with this??', 'start': 771.47, 'duration': 1.281}, {'end': 774.371, 'text': 'How long can you make this story??', 'start': 772.971, 'duration': 1.4}, {'end': 775.652, 'text': 'What is the story??', 'start': 774.411, 'duration': 1.241}, {'end': 779.353, 'text': 'What types of other things might you assign and pick randomly or assign in advance?', 'start': 776.192, 'duration': 3.161}, {'end': 782.033, 'text': 'But I just want to show you one other thing.', 'start': 779.733, 'duration': 2.3}, {'end': 787.815, 'text': 'Tracery also includes modifiers.', 'start': 783.094, 'duration': 4.721}, {'end': 797.461, 'text': 'So for example, if I put .s here, .s will pluralize whatever character is picked.', 'start': 788.115, 'duration': 9.346}], 'summary': 'Exploring creativity with tracery, including modifiers for pluralization.', 'duration': 28.291, 'max_score': 769.17, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C3EwsSNJeOE/pics/C3EwsSNJeOE769170.jpg'}, {'end': 886.944, 'src': 'embed', 'start': 862.416, 'weight': 3, 'content': [{'end': 868.122, 'text': 'and the features are kind of explained through the various various possibilities here.', 'start': 862.416, 'duration': 5.706}, {'end': 872.648, 'text': "OK, so there's so much more here that I want to look into that I haven't.", 'start': 869.464, 'duration': 3.184}, {'end': 878.917, 'text': "So maybe someday I'll come back and show you some other additional advanced, so to speak, features of the tracery library.", 'start': 872.688, 'duration': 6.229}, {'end': 881.62, 'text': 'So this example will be published for you.', 'start': 879.197, 'duration': 2.423}, {'end': 882.722, 'text': 'I encourage you to read it.', 'start': 881.641, 'duration': 1.081}, {'end': 883.822, 'text': 'Write your own grammar.', 'start': 882.782, 'duration': 1.04}, {'end': 886.944, 'text': 'Of course, you can use emojis as possibilities, as you can see.', 'start': 883.842, 'duration': 3.102}], 'summary': 'Exploring advanced features of the tracery library and encouraging customization with emojis and own grammar.', 'duration': 24.528, 'max_score': 862.416, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C3EwsSNJeOE/pics/C3EwsSNJeOE862416.jpg'}], 'start': 472.43, 'title': 'Tracery grammar and library features', 'summary': 'Explores the use of a tracery grammar to generate sentences with multiple possibilities and probabilities, and explains the features of the tracery library, including the assignment of production rules, usage of modifiers, and collaborative grammar creation.', 'chapters': [{'end': 672.083, 'start': 472.43, 'title': 'Tracery grammar and story generation', 'summary': 'Explores the use of a tracery grammar to generate sentences with multiple possibilities and probabilities, as well as the process of creating a story with a randomly chosen hero and monster.', 'duration': 199.653, 'highlights': ['The chapter explains the use of a tracery grammar to generate sentences with multiple possibilities and probabilities. The speaker demonstrates using a tracery grammar to create sentences with multiple possibilities and explains the probabilities associated with each option.', 'The process of creating a story with a randomly chosen hero and monster is detailed. The speaker discusses the process of selecting a hero and a monster at random and the need to ensure that the same hero is chosen both times in the story.', 'The demonstration includes examples of sentences and stories generated using the tracery grammar. Examples of sentences and stories generated using the tracery grammar are provided, showcasing the variety of possibilities and outcomes based on the defined rules and probabilities.']}, {'end': 987.502, 'start': 672.523, 'title': 'Tracery library features', 'summary': 'Explains the features of the tracery library, including the assignment of production rules, usage of modifiers, and collaborative grammar creation, showcasing how it can generate a variety of stories with random character and villain selections.', 'duration': 314.979, 'highlights': ['The tracery library allows the assignment of production rules, enabling the generation of a variety of stories with random character and villain selections. The library has a mechanism for assigning a production rule, allowing for the generation of stories with random character and villain selections.', 'Tracery includes modifiers such as pluralization and capitalization, offering flexibility in story generation without the need for specific rules for each modification. Tracery features modifiers like pluralization and capitalization, providing flexibility in story generation without the need for specific rules for each modification.', 'The potential for collaborative grammar creation on GitHub is mentioned, encouraging contributions to expand the creativity and variety of generated stories. The chapter discusses the potential for collaborative grammar creation on GitHub, encouraging contributions to expand the creativity and variety of generated stories.']}], 'duration': 515.072, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C3EwsSNJeOE/pics/C3EwsSNJeOE472430.jpg', 'highlights': ['The tracery library allows the assignment of production rules, enabling the generation of a variety of stories with random character and villain selections.', 'The chapter explains the use of a tracery grammar to generate sentences with multiple possibilities and probabilities.', 'Tracery includes modifiers such as pluralization and capitalization, offering flexibility in story generation without the need for specific rules for each modification.', 'The demonstration includes examples of sentences and stories generated using the tracery grammar.']}], 'highlights': ['The tracery library for JavaScript enables creative text generation using context-free grammars, allowing for the generation of stories and even the creation of a Twitter bot.', 'An example of text generation using tracery is showcased, featuring stories created by a five-year-old and an eight-year-old, demonstrating the flexibility and creative potential of tracery for generating narratives.', 'The chapter demonstrates the use of tracery, a JavaScript library, to generate text with the incorporation of color and emojis.', 'The tracery library allows the assignment of production rules, enabling the generation of a variety of stories with random character and villain selections.', 'The chapter explains the use of a tracery grammar to generate sentences with multiple possibilities and probabilities.', "The concept of expansion and flattening in grammar generation is explained, with 'flatten' being used to obtain the end result of the generated text.", 'Tracery includes modifiers such as pluralization and capitalization, offering flexibility in story generation without the need for specific rules for each modification.']}