Lorem Ipsum Generator Lorem Ipsum is placeholder text used when preparing layout without wanted to have content already filled.

One of its key features over using some arbitrary text is that it is nonsense.
It isn't even valid latin (though it is close).
This prevents anyone being shown the layout from becoming distracted reading the text.

The other key feature is that it looks like real language.
The words are the right length, and the characters occur with the right distributions.

A problem is that the Lorem Ipsum is not necessarily good gobbldy-gook for all languages, or even for all subject matter.
We expect that the distribution of letters would be different in a novel, than in a scientific article.

Your task thus is to create a tool that when given an example of text, generate a lorum ipsum style gobbldy-gook that is a suitable imitation of the characteristics of that text.

The Task

Given an input in UTF8 text input-text, and a number x.
Output x characters of gobbldy-gook following the style of that text.

It may be assumed that words are separated using the space character in the input text.

You may take the input in any reasonable form (though it must be able to accept UTF-8). Eg reading from STDIN, reading from file, as a string passed to the function etc.
Similar for output.

Critria


Must not be real correct text in the language of input-text


In particular must contain no words with more than 3 characters from input-text.
This can be trivially avoided by using a hashset to ban all words from input-text from occurring in the output

Must look like it could have been real text from the language of input-text.


That is to say it must have the correct letter and word length distributions that is convincing to the eye of the reader.


It is up to the implementation if they take this to mean unigram, bigram, trigram or other statistics for the distributions.
The goal is for it to look right




Judging Texts

For purposes of judging please provide 256 characters of output based on each of the following public domain texts:


De Finibus, Book 1, sections 32–3, by Cicero.txt
Pride and Prejudice, By Jane Austen
Die Verwandlung, by Franz Kafka
The Magna Carta


gist with all files

Those that these are all UTF-8 encoded, and in particular Die Verwandlung, being in German uses many characters outside [a-zA-Z]
Python 3

import string
import random

with open('lorem.txt') as f:
    text = f.read()
number = eval(input("Input number: "))

dictionary = ''.join(ch for ch in text if ch not in set(string.punctuation)).split(" ")

chars = []

for word in dictionary:
    for char in word:
        chars.append(char)

chars = list(set(chars))

occurences = {}

for char in chars:
    occurences[char] = []

for word in dictionary:
   for idx, char in enumerate(word):
        try:
            occurences[char].append(word[idx+1])
        except IndexError:
            pass

lengths = [len(x) for x in dictionary]

result = ""

for _ in range(number):
    length = random.choice(lengths)
    word = random.choice(chars)
    for _ in range(length):
        try:
            word += random.choice(occurences[word[-1]])
        except IndexError: 
            break
    result += word + " "

print(result)


Takes text input through a file named lorem.txt and number of words through STDIN.

Samples:

De Finibus:


  bolute moresu xisi libospssev lolu ute tamqump Sercolimo mnci iaerue unt xptemp ptur xiui mumnsc ner citerum hiositius fun Set llu hibol etet mpesi amitap voserata mol iumol ospe pte ell asequmut


Die Verwandlung:


  Frehwauchmi «
      vo ineic venzundenwasender geitende «
      darenenserttem Semint estt Scklode
      Zur
      g ZenÂ»e Orer urd cher
      s
      Bet
      kun renaunn


Pride and Prejudice:


  paime k
      hothenoc 5
      “ 230
      erth ZZWedomincab Mrevoueim Vifedrctogei Come Kidi yol qul
      “Thant Kie Rag 41
      mf vate 12
      Eled 8
      Dathed 1
      mb Bed
      “Y merie xto zasorl h’sh ghasst Wha quce skeniat zan dishond
       othing
      hare hing din


And finally, the Magna Carta:


  wincand zisend
      s
       Pes CEFured indons fequ dindshay ranen Gofun
       OURore ibec 6248 Rofonestheasaven
      sul nthal
      232 rend
      matyont r
       uiconlicend
       ucriof 7 ashesevenye Gerd
       BEndrouse IIns jurig 20000 UREndit mandira 0000000000s
      a
      wic 47 Enccet


It's not my best work. 

All I'm doing here is some simple Markov chain recreation of the original text, with word lengths taken from a list of all lengths in the given text.  

I sort of hoped for better results, but oh well.