Welcome to Affix Grammar!
Affix Grammar is a tool which lets you write grammars, and randomly generates sentences based on those grammars. You can use it to:
- generate stories (kinda like Mad Libs),
- test out context-free grammars,
- test your knowledge of the grammar of a human language you're learning!
Here's a simple grammar which generates "hello world" sentences from different languages.
Click the Generate button a few times to see the sentences that are produced!
You can edit this grammar by clicking on the Edit tab.
rule start = hello_world.Language "(" + @Language + ")" rule hello_world.Language =
.english -> "Hello, World!"
.spanish -> "¡Hola Mundo!"
.japanese -> "こんにちは世界!"
.arabic -> "مرحبا بالعالم!"
.indonesian -> "Salamu, Dunia!"
.uyghur -> "ياخشىمۇسىز دۇنيا!"
.greek -> "Γειά σου Κόσμε!"
.ukrainian -> "Привіт Світ!"
.thai -> "สวัสดีชาวโลก!"
.french -> "Bonjour le monde!" data Language
= english ("English")
| spanish ("Spanish")
| japanese ("Japanese")
| arabic ("Arabic")
| indonesian ("Indonesian")
| uyghur ("Uyghur")
| greek ("Greek")
| ukrainian ("Ukranian")
| thai ("Thai")
| french ("French") Learn
Want to learn how to write your own grammars? For a beginners tutorial, click here!
About the Project
Affix Grammar (name subject to change) was heavily inspired by Dr. Kate Compton's Tracery Project, and incorporates additional ideas from the paper Affix Grammars for Natural Languages about Affix Grammars.
The project repository is located here.
Technical Details
The Affix Grammar parsing and generation engine is written in the Rust language and compiled to Webassembly. Markdown rendering is done by a Rust library called pulldown-cmark. This frontend is written in Vue.js, and the text editor is Ace.