Building a Web-based Generator from Data
For this exercise, we’ll begin to build our web-based generator using one method for combining both extracted data from texts and a Tracery grammar.
- Use your local retrieval-augmented generation set-up to explore a set of texts and pull characteristic passages and themes. Break down sections of this into a pattern for your generator: for instance, my example draws from science fiction texts with descriptions of aliens, and uses those passages as models for the grammar for a “sightings” generator.
- Using a similar workflow as our previous distant read, pull nouns and other keywords from a set of texts. Then, iteratively work through them to build an extended grammar with the goal of creating a robust and extensive vocabulary for every option in your grammar. Your options for each word should be data-driven, reflecting a set of possible words pulled from source material. Cite the source material in your final text generator. Here’s the sample workflow.
- Set up your grammar in a json file, and download both the Tracery library and jQuery - for this exercise, we’ll use jQuery to handle our dynamic display, in part because it is well-documented.
- Set up the web generator project with a HTML file and either inline or external CSS. Generate the foundational code to load in the JSON file and display a generated text.
- Iterate to expand the elements generated: use embedded HTML code to handle spacing, and think about how you might build every aspect of the document. There are three primary approaches to this type of generation: either replace all the content after a timed cycle, incorporate a button or user interaction to generate a new version, or build a dynamically scrolling piece ala Taroko Gorge.
- Incorporate an appropriate SVG and append it to an image holder element on your page. Depending on your format, you might want to place this behind the text or alongside moving text.
The sample for this first stage can be found and copied from here.