NaNoGenMo / 2017

National Novel Generation Month, 2017 edition.
https://nanogenmo.github.io
185 stars 7 forks source link

2d Markov #125

Open enkiv2 opened 6 years ago

enkiv2 commented 6 years ago

I treat an input as a 2d array -- lines vs words -- and pad it so that all of the lines are of the maximum length. Then, I make a markov model wherein, for each word, I keep track of the words that occur above, below, before, and after.

To generate the output, I create a blank word array of equivalent size, seed exactly one cell from the input, and then fill in the rest of the document by cross formations -- starting from the seeded cell, I fill in all four adjacent sections (by randomly choosing from the markov model, with the existing item in that cell -- if any -- added as an option), and then proceed in all directions.

Code: https://github.com/enkiv2/misc/blob/master/nanogenmo-2017/2d-markov.py Output: https://github.com/enkiv2/misc/blob/master/nanogenmo-2017/2dneuro.txt

Next steps: I would like to use word2vec to sum the existing word with the newly chosen option, rather than typically replacing it altogether.

enkiv2 commented 6 years ago

Added suport for word2vec interpolation.

Output: https://github.com/enkiv2/misc/blob/master/nanogenmo-2017/2dneuro-2.txt

enkiv2 commented 6 years ago

To make it a little clearer, I made a tabular version:

http://www.lord-enki.net/2dneuro.html

http://www.lord-enki.net/2dneuro-2.html