Git Product home page Git Product logo

babbler's Introduction

babbler

Randomly sampling vaguely grammatical nonsense since 2009

This repository contains some experiments in sampling English text with stylistic structure (but very little semantic sense). It is built on a fairly complex fragment of English grammar encoded in a 3 different ways:

* `grammar.pl` -- A fairly straightforward representation as a DCG
* `grammar_attr.pl` -- An attribute or feature grammar using graph unification
* `grammar_gap.pl` -- Using the gap threading version of the sampling meta-interpreter from sampledcg

The latter two are untested since several years ago and probably don't work. The graph unification algorithm is based on code by Bob Carpenter.

It requires the Prolog lexical databases which are available at https://code.soundsoftware.ac.uk/hg/plex

Also requires the following SWI Prolog packs:

plrand
genutils
textutils
dcgutils
sampledcg (available at https://github.com/samer--/sampledcg)

Some sample outputs can be found in the examples directory.

The top level file poetry.pl can be set to use either biglex or littlelex (from the plex repository referenced above). The former uses a big lexicon derived mainly from the Oxford Advanced Learners Dictionary, and therefore has lots of great words in it, but can result in a somewhat shotgun approach to vocabulary selection. The smaller lexicon was handwritten.

Sample session:

$ swipl -s poetry.pl
?- main(100,s).
>> resample_probs(dirichlet(2)).
>> render(fmt,rep(5,line(s))).

This will (1) generate and throw away 100 random sentences, (2) enter a stateful shell that keeps track of probability distributions over choices in the grammar, initialised with the choices made while sampling the initial 100 sentences, (3) sample new probability distributions for all known distributions from a Dirichlet process with concentration parameter 3 and (4) sample 5 lines from the resulting grammar. I take no responsibility for any of the nonsense and occasional filth that might emerge from this.

The 'renderer' fmt writes the output to the terminal. If you are using a Mac, you can get the machine to recite the output as well by using fmt && async(say(Voice)) where Voice is one of the voice names. You can log the output to a file with fmt && append(Filename). See render/2 in the textutils pack for more information.

babbler's People

Contributors

samer-- avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.