Skip to content
Markov chains in inefficient JS.
JavaScript HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md
public_index.html
sanitization_used_for_sample.txt
underscore.js

README.md

Markov In Inefficient JS

View public_index.html for a sample.

These chains are generated with two independent dictionaries of 2-grams and 3-grams. Sentences are split into words and these words are used to index the following words. For instance, the following sentences:

to be or not to be that is the question

...would be recategorized as:

to: ['be', 'be']
be: ['or']
or: ['not']
not: ['to']
that: ['is']
...etc

Note that the duplicated be's are intentional; a random index in the to array can then be used to pick a next word, weighted for probability.

3-grams are indexed as:

'to be': ['or']
'be or': ['not']
...etc

and so on.

It's horribly inefficient, but... So sue me.

More information here.

You can’t perform that action at this time.