Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.jayway.jsonpath.JsonPath
- import java.net.URL
- import java.util.*
- fun main(args: Array<String>) {
- val rnd = Random()
- val regex = "[а-я]+".toRegex()
- val words = URL("https://2ch.hk/pr/res/801885.json").readText()
- .let { JsonPath.read<List<String>>(it, "$.threads[0].posts[*].comment") }
- .map { it.toLowerCase() }
- .flatMap { regex.findAll(it).map { it.value }.toList() }
- (1..20)
- .map {
- (1..2 + rnd.nextInt(4))
- .map { words[rnd.nextInt(words.size)] }
- .joinToString(separator = " ")
- }
- .forEach { println(it) }
- }
Advertisement
Add Comment
Please, Sign In to add comment