Tag Archives: Markov Chains

Texts I could have written – Generated Sentences (Markov Chains)

ENIn April, I wrote a text generator in Python – find here the article in French – long live Markov Chains! I can now generate sentences by feeding my generator with my texts – here in English.

Roughly, my algorithm will compute the probability of my writing some words in my texts, after Word 1 and Word 2. For instance, in my texts, after “It is”, let’s say there is a 10% chance of  having “obvious”, 20% “raining”, 25% “a”, and so on. Thanks to this data my generator will choose words according to those probabilities. If my generator first chooses “It is” as the beginning of a sentence, there is a 10% chance the next word will be “obvious”, 20% “raining”, etc.

The resulting sentences are often funny, always very surreal.

Selected generated sentences:

“I will be me. I was twelve, the trend in art was realistic descriptions of the deep maze inside… Recovered memories suddenly propagate, What he recalls from her throws him in a modernist museum.”

Continue reading Texts I could have written – Generated Sentences (Markov Chains)

Jabberwocky: Language Detection and Gibberish

ENWritten Language Detection

Creating an algorithm to guess the language of a text can be very useful – for instance, say you have a multilingual RSS feed and want a text-to-speech software to pronounce the sentences, for instance:

Continue reading Jabberwocky: Language Detection and Gibberish

Textes que j’aurais pu écrire – Phrases générées grâce aux chaînes de Markov

fr-airship

En Avril, pour un petit jeu, j’ai écrit en Python un générateur de textes – vive les chaînes de Markov ! Mais du coup j’ai aussi généré des phrases en nourrissant le générateur de la plupart de mes textes et projets – ici en français.

En gros, mon algorithme note les probabilités d’avoir tel ou tel mot dans mes textes, après Mot 1 et Mot 2. Par exemple, après “Il est”, mettons qu’il y ait 10% de chances dans mes textes que le mot suivant soit “évident”, 10 % “propre”, 5% “courroucé”, etc. Ensuite grâce à cette base, le générateur va choisir des mots avec les probabilités indiquées. Si le générateur a choisi “Il est” pour commencer la phrase, il y a 10% de chances que le mot suivant soit “évident”, et ainsi de suite.

J’ai ainsi créé quelques phrases parfois comiques, qui ressemblent à ce que j’écris, mais en un peu plus surréaliste… Je vais essayer d’en générer à partir de mes textes en anglais, mais ce sera pour plus tard.

Extraits choisis :

“Alessandro invita la jeune fille qui put sortir des lèvres de Lilith.”

“Une autre femme sort de la journée dans un orphelinat, sans que l’on voit dans une immense salle de sécurité de la présence d’un boa gigantis.”

Continue reading Textes que j’aurais pu écrire – Phrases générées grâce aux chaînes de Markov