Search code examples
pythonrandomprogramming-languagesdynamically-generated

Generate meaningful text from random letters


Is there's someway to generate a meaningful text from random letters as ex. if I type

sbras

the program should give this or something similar

saber

if the above request can't get a good answer , then

I like the generated text and/or numbers on screens in hack & technologies movies

is there's someway to generate a text or numbers , I mean with typing animations

I can use my own text and numbers in python print but won't give me the typing animations like movies

if the above requests can done in python ,that will be great

but if can done in other language , I will be thankful too


Solution

  • As for your first question: Well, that depends on how specifically you want it. If you want to do it real-time, i.e. you want proper words to appear as you type random stuff, well, good luck with that. If you have a text with random letters, you could afterwards look for proper anagrams of every word in the text. You will require a list of proper words to see if they are anagrams, however.

    Note that also "a sentence with proper words" is a completely different thing than "a proper sentence". The former is done relatively easy with enough time and effort, while the latter is (close to) impossible to do, as you require your program to have knowledge of both grammar and the type of words (i.e. noun, verb, preposition...).

    As for your second question, print is indeed instant. However, you could use the time module to get the wanted effect. One example:

    import time
    import sys
    sentence = "The quick brown fox jumps over the lazy dog"
    for c in sentence:
      sys.stdout.write(c)
      time.sleep(0.1)
    

    You can adjust the 0.1 to your liking - it's the sleep time in seconds. You could even make it random within some interval. For the reason I used sys.stdout.write as opposed to print c or print c, see this question.