Follow

Playing with Markov chains;
sentences generated from journal entries :)

@joshavanier
haha I love markov-chain-based texts. the algorithm is simple and the results are usually amazing.
do you mind telling us more or less how do you build the chain?

@joshavanier
(I did one a while ago with some texts of Roberto Arlt here say-something-arlt.herokuapp.c but I remember I struggled a bit to not make it enter in endless loops, and to control the amount of possible variations (I remember that I used a config parameter that makes it aware of the n previous words, but having it higher than 2 was just extracting literal phrases from the book most of the time :( )

@joshavanier
I parsed the first 3 chapters from "Los siete locos" from here: biblioteca.derechoaleer.org/bi

I have the chain dumped to a file, I can take some numbers out if you are interested

@joshavanier Ok, I took a look. The structure is very similar to what you have, pair of words associated to possible next words.
It has 47905 pairs.

40442 of those pairs have a single option as next word (I guess that's why it generates almost always textual extracts)

There's one entry that has 4127 possibilities. When I took a look, I found out it was a triple space 🤷‍♂️

looks like if I do a more intelligent parsing and some cleanup of the model it might return more interesting results :)

@joshavanier I can upload the code somewhere if you are interested (CW: is quite hacky and zero-polished :P)

@f3r That's a lot of pairs. Sounds like there's more to your implementation than what I have; I'd love to look at it

It's nothing fancy 

@f3r I just split my journal entries into word pairs + an ending word so that sentence like "W X Y Z" would be:

W X
X Y
Y Z
Z

Then it's just a little recursion:
- Choose a word
- Filter the model; you only want phrases that start with the chosen word
- Choose a random phrase from that and use that phrase's 2nd word as the new chosen word and repeat

The recursion ends if the randomly chosen phrase is just a single word.

Sign in to participate in the conversation
Merveilles

Merveilles is a community project aimed at the establishment of new ways of speaking, seeing and organizing information — A culture that seeks augmentation through the arts of engineering and design. A warm welcome to any like-minded people who feel these ideals resonate with them.