Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Too many Underscore is generated. #44

Open
m-shaka opened this issue May 18, 2018 · 0 comments
Open

Too many Underscore is generated. #44

m-shaka opened this issue May 18, 2018 · 0 comments

Comments

@m-shaka
Copy link

m-shaka commented May 18, 2018

Hi. I want to generate string that matchs regex \\w, but generated string contains obviously too many Underscores. Does java.util.Random's unevenness cause this?

The following is sample code. (I'm Sorry, I use Kotlin, not Java)

fun main(args: Array<String>) {
    val value = Generex("\\w{1000}").random()
    val counter = mutableMapOf<Char, Int>()
    for (v in value.toList()) {
        val c = counter.get(v)
        when (c) {
            null -> counter.put(v, 1)
            else -> counter.put(v, c + 1)
        }
    }
    counter.toList().sortedByDescending { it.second }.take(10).forEach {
        println("char: ${it.first}, count: ${it.second}")
    }
}

//    sample result
//    char: _, count: 225
//    char: 3, count: 38
//    char: 8, count: 30
//    char: 4, count: 29
//    char: 9, count: 28
//    char: 5, count: 27
//    char: 1, count: 27
//    char: 7, count: 24
//    char: 2, count: 24
//    char: 0, count: 22
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant