<commit_before>Permutation Poetry
==================

Permutation Poetry is a small Python program that uses the vast NLTK library to
generate original poetry from permutations of classic prose. It reads classic
texts like <NAME>'s "Emma" and Milton's "Paradise" and finds sentences
with rhyming endings and approximately the same number of syllables. It then
picks pairs of such sentences and outputs a set of couplets that sometimes
make sense.

Examples
--------

A single couplet with 6 syllables per line and a rhyming depth of 3 phonemes on
the last word:

    It was as follows
    Aye, we men are sad fellows.

With approximately 10 syllables per line:

    We are growing a little too nice,
    I WILL be more collected--more concise.
    He is black at heart, hollow and black!
    It had been begun several days back.

Another example:

    Her observation had been pretty correct,
    my line of conduct will be more direct.
    Every invitation was successful,
    you have been here only to be useful.

And now 12 syllables per line -- so close to making sense!

    A widow Mrs Smith lodging in Westgate Buildings!
    Your dear mother was so clever at all those things!
    We have seen nothing of him since November,
    we want only two more to be just the right number.

And now getting ambitious with 16 syllables per line:

    You are speaking of letters of business; mine are letters of friendship,
    you are always labouring and toiling, exposed to every risk and hardship.

Installation
------------
Permutation poetry requires Python and the NLTK library with some additional
corpora installed. On a modern Linux system, this is quite easy. With pip
installed, running the following command installs NLTK:

    pip install nltk

Then, start the python shell and execute the following commands to install
the CMU Pronunciation Dictionary and the Project Gutenberg corpus.

    import nltk
    nltk.download()

That should pop up the NLTK Downloader window. Click on the "Corpora" section,
select "cmudict" and "gutenberg" and click "Download". That should be all.

To test if everything works, see which texts are available to NLTK by running
the following commands in the Python shell:

    from nltk.corpus import gutenberg
    gutenberg.fileids()

Usage
-----
```
    ./poet.py [number of couplets] [number of syllables per line] [rhyming threshold]

       number of couplets:  Number of sentence pairs to generate
       syllables per line:  Syllable length of extracted sentences
       rhyming threshold:   Constrain sentence pairs by # of shared trailing phonemes
```
    Defaults:

       * number of couplets: 5
       * syllables per line: 10
       * rhyming threshold:  2<commit_msg>Add link to Github pages.<commit_after>Permutation Poetry
==================

Permutation Poetry is a small Python program that uses the vast NLTK library to
generate original poetry from permutations of classic prose. It reads classic
texts like <NAME>'s "Emma" and Milton's "Paradise" and finds sentences
with rhyming endings and approximately the same number of syllables. It then
picks pairs of such sentences and outputs a set of couplets that sometimes
make sense.

Examples
--------

A single couplet with 6 syllables per line and a rhyming depth of 3 phonemes on
the last word:

    It was as follows
    Aye, we men are sad fellows.

With approximately 10 syllables per line:

    We are growing a little too nice,
    I WILL be more collected--more concise.
    He is black at heart, hollow and black!
    It had been begun several days back.

Another example:

    Her observation had been pretty correct,
    my line of conduct will be more direct.
    Every invitation was successful,
    you have been here only to be useful.

And now 12 syllables per line -- so close to making sense!

    A widow Mrs Smith lodging in Westgate Buildings!
    Your dear mother was so clever at all those things!
    We have seen nothing of him since November,
    we want only two more to be just the right number.

And now getting ambitious with 16 syllables per line:

    You are speaking of letters of business; mine are letters of friendship,
    you are always labouring and toiling, exposed to every risk and hardship.

Installation
------------
Permutation poetry requires Python and the NLTK library with some additional
corpora installed. On a modern Linux system, this is quite easy. With pip
installed, running the following command installs NLTK:

    pip install nltk

Then, start the python shell and execute the following commands to install
the CMU Pronunciation Dictionary and the Project Gutenberg corpus.

    import nltk
    nltk.download()

That should pop up the NLTK Downloader window. Click on the "Corpora" section,
select "cmudict" and "gutenberg" and click "Download". That should be all.

To test if everything works, see which texts are available to NLTK by running
the following commands in the Python shell:

    from nltk.corpus import gutenberg
    gutenberg.fileids()

Usage
-----
```
    ./poet.py [number of couplets] [number of syllables per line] [rhyming threshold]

       number of couplets:  Number of sentence pairs to generate
       syllables per line:  Syllable length of extracted sentences
       rhyming threshold:   Constrain sentence pairs by # of shared trailing phonemes
```
    Defaults:

       * number of couplets: 5
       * syllables per line: 10
       * rhyming threshold:  2

Demo
----

[Paired with Flickr image search and Google web fonts](http://mayanklahiri.github.io/permutation-poetry)
{'fraction_non_alphanumeric': 0.05273542600896861, 'fraction_numerical': 0.004304932735426009, 'mean_word_length': 3.4009471191791634, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6283351', 'n_tokens_mistral': 1534, 'n_tokens_neox': 1412, 'n_words': 807}