Skip to content
Itay Niv edited this page Oct 24, 2018 · 16 revisions

Markov Chains and Context-Free Grammars

It is not required to write any new code for this assignment. You are welcome to simply run one or more of the provided examples with your own data. You can document the results in a blog post (or link to a web page where the text is generated. I'll include some other ideas below in case you are feeling ambitious.

Markov Chain

Use one of the existing examples to generate text with your own input data. Experiment with the "order" and "maximum" length variables. Try mixing multiple texts. Copy paste your favorite outputs from the browser and document in a blog post.

Some additional ideas:

  • Design a webpage to display the output of a markov generator a la Allison Parrish's ITP course creator.
  • Create a bot that generates its output based on a markov chain.
  • Use a markov chain on something other than text. Record your own sequence of daily habits. Try musical notes. Could colors or shapes be generated with a markov chain? What else?
  • Animate the process of the markov chain in action.
  • Visualize n-gram frequencies.

Context-Free Grammar

Invent your own grammar and generate text. There are lots of example grammars you can find online, though you may have to reformat them to be the grammar syntax depending on which example you use.

Feel free to use Tracery or even try Allison Parrish's new Seaduck. And there is of course my p5 only examples as well.

Getting results from a context-free-grammar can be tricky. Something short and sweet, highly structured ideas may work well. For example.* A coffee drink order generator.

  • An apology generator.
  • An ITP project idea generator.
  • A knock knock joke generator.

Some other ideas:

  • Rework any of the example programs to use something other than text (or, at least, text that represents language) as its basic unit. For example: musical notes, songs in playlists, pixels in an image, shapes in a drawing, etc.
  • Build a grammar that pulls its terminal words from Wordnik.
  • Build a grammar based on a source text as demonstrated heresource code.

Name and URL