Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I generate pseudo-random "readable" strings in Java?

Generating a truly random string of a given length is a fairly straightforward (and already-well-covered) task.

However; I'd like to generate a "pseudo" random string with the additional constraint that it be relatively easily readable (to a native-English reader.)

I think another way to say this is to say that the generated string should consist of "recognizable syllables." For example, "akdjfwv" is a random string, but it's not recognizable at all. "flamyom"; however, is very "recognizable" (even though it's nonsense.)

Obviously, one could make a long list of "recognizable syllables," and then randomly select them.

But, is there a better way to do something like programmatically generate a "recognizable syllable," or generate a "syllable" and then test it to see if it's "recognizable"?

I can think of several ways to go about this implementation, but if someone has already implemented it (preferrably in Java or C#,) I'd rather re-use their work.

Any ideas?

like image 566
Jared Avatar asked Aug 20 '09 14:08

Jared


1 Answers

You could try implementing a Markov chain and give it a suitable passage to process. There is a Java implementation that may work for you.

This is a sample from interpolating between Genesis in English and Genesis in Spanish (N = 1):

In bersaran thelely and avin inder tht teathe m lovig weay waw thod mofin he t thte h fupiteg s o t llissed od ma. lllar t land fingujod maid af de wand tetodamoiz fosu Andesp. ersunen thenas lowhejod whipanirede tifinas Gofuavithila d gió Y Diche fua Dios co l, liens ly Y crerdíquen ticuesereregos hielase agúnd veumarbas iarasens laragún co eruerá laciéluelamagúneren Dien a He.

like image 66
Rich Seller Avatar answered Sep 17 '22 18:09

Rich Seller