madlang: Randomized templating language DSL

[ bsd3, library, text ] [ Propose Tags ]

Please see README.md


[Skip to Readme]

Modules

[Last Documentation]

  • Text
    • Text.Madlibs

Flags

Automatic Flags
NameDescriptionDefault
llvm-fast

Enable build with llvm backend

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4, 0.1.0.5, 1.0.0.0, 1.0.0.1, 1.0.1.0, 1.1.1.0, 1.1.2.0, 1.1.3.0, 2.0.0.0, 2.0.0.1, 2.0.1.0, 2.0.1.1, 2.0.1.2, 2.1.0.0, 2.1.0.1, 2.1.0.2, 2.1.0.3, 2.1.0.4, 2.1.1.0, 2.1.1.1, 2.1.1.2, 2.1.1.3, 2.1.2.0, 2.2.0.1, 2.3.0.2, 2.3.0.3, 2.3.0.4, 2.3.0.5, 2.3.0.6, 2.3.1.0, 2.3.1.1, 2.3.2.0, 2.4.0.0, 2.4.0.1, 2.4.0.2, 2.4.1.0, 2.4.1.1, 2.4.1.2, 2.4.1.3, 2.4.1.4, 2.4.1.5, 2.4.1.6, 2.4.2.0, 2.4.2.1, 2.4.2.2, 2.4.2.3, 2.4.2.4, 2.4.2.5, 2.4.2.6, 2.4.2.7, 2.4.2.8, 2.4.2.10, 2.4.2.11, 2.4.2.12, 2.4.2.13, 2.4.2.14, 2.4.2.20, 2.4.2.21, 2.4.2.22, 2.4.2.25, 3.0.0.0, 3.0.0.1, 3.0.0.3, 3.0.0.4, 3.1.0.0, 3.1.0.1, 3.1.0.2, 3.1.0.5, 3.1.0.6, 3.1.0.7, 3.1.0.10, 3.1.1.0, 3.1.1.1, 3.1.1.6, 3.1.1.7, 3.1.1.13, 3.1.1.18, 3.1.1.20, 3.1.1.21, 3.1.2.0, 3.2.0.0, 3.2.0.1, 4.0.0.0, 4.0.0.1, 4.0.0.2, 4.0.0.3, 4.0.0.4, 4.0.1.0, 4.0.1.1, 4.0.2.0, 4.0.2.1, 4.0.2.2, 4.0.2.5, 4.0.2.6, 4.0.2.7, 4.0.2.8, 4.0.2.9, 4.0.2.11, 4.0.2.12, 4.0.2.13, 4.0.2.14, 4.0.2.15, 4.0.2.16
Dependencies ansi-wl-pprint (>=0.6.7.3 && <0.7), base (>=4.9.1.0 && <4.10), containers (>=0.5.7.1 && <0.6), lens (>=4.15.1 && <4.16), madlang (>=2.0.1.0 && <2.1), megaparsec (>=5.2.0 && <5.3), mtl (>=2.2.1 && <2.3), mwc-random (>=0.13.5.0 && <0.14), optparse-applicative (>=0.13.2.0 && <0.14), text (>=1.2.2.1 && <1.3), tibetan-utils (>=0.1.1.2 && <0.2) [details]
License BSD-3-Clause
Copyright Copyright: (c) 2016 Vanessa McHale
Author Vanessa McHale
Maintainer tmchale@wisc.edu
Category Web
Home page https://github.com/vmchale/madlang#readme
Source repo head: git clone https://github.com/vmchale/madlang
Uploaded by vmchale at 2017-03-19T05:34:18Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Executables madlang
Downloads 61174 total (115 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2017-03-19 [all 3 reports]

Readme for madlang-2.0.1.0

[back to package description]

Madlang DSL for generating random text

Build Status

This is the Madlang DSL for generating random text. There is also a vim plugin, available here.

It enables you to generate random templated text with very little effort or expertise.

It can be used for twitter bots and provides human-readable syntax for Markov chains often used in natural language processing.

Exmaples

An exmaple is worth a thousand words, so suppose you wanted to generate a mediocre fortune telling bot. You could write the following code:

:define person
    0.7 "A close friend will "
    0.3 "You will "
:define goodfortune
    0.2 person "make rain on the planet Mars"
    0.8 "nice things will happen today :)"
:define fortune
    0.5 "drink a boatload of milk"
    0.5 "get angry for no reason"
:return
    0.8 person fortune
    0.2 goodfortune

There are two "statements" in madlang, :define and :return. :return is the main string we'll be spitting back, so there can be only one per file. :define on the other hand can be used to make multiple templates. These templates are combinations of strings (enclosed in quotes) and names of other templates.

Of course, you can't have a circular reference with names - if goodfortune depends on fortune while fortune depends on goodfortune, we end up with either no fortune or an infinite fortune. So we throw an error.

Using the libary

The main function you'll want to use is probably runFile; it reads a file and generates randomized text:

 λ:> runFile [] "test/templates/gambling.mad"
 "heads"

Haddock documentation of all available functionality is located here.

Installation

Releases

If you're on windows or linux, grabbing release binaries is probably the easiest. Find them here.

Stack

Download stack with

curl -sSL http://haskellstack.org | sh

Then run stack install madlang and you'll get the madlang executable installed on your path.

Use

To use it, try

 $ madlang run fortune-teller.mad

You can do madlang --help if you want a couple other options for debugging.

Syntax Highlighting

Syntax highlighting for the DSL is provided in the vim plugin here. It includes integration with syntastic.