Guest User

Untitled

a guest
Jul 25th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. import com.jayway.jsonpath.JsonPath
  2. import java.net.URL
  3. import java.util.*
  4.  
  5. fun main(args: Array<String>) {
  6.     val rnd = Random()
  7.     val regex = "[а-я]+".toRegex()
  8.  
  9.     val words = URL("https://2ch.hk/pr/res/801885.json").readText()
  10.         .let { JsonPath.read<List<String>>(it, "$.threads[0].posts[*].comment") }
  11.         .map { it.toLowerCase() }
  12.         .flatMap { regex.findAll(it).map { it.value }.toList() }
  13.  
  14.     (1..20)
  15.         .map {
  16.             (1..2 + rnd.nextInt(4))
  17.                 .map { words[rnd.nextInt(words.size)] }
  18.                 .joinToString(separator = " ")
  19.         }
  20.         .forEach { println(it) }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment