create output in console method

This commit is contained in:
ZhigalskiiIvan 2023-03-24 19:18:30 +03:00
parent c08e843510
commit 87e744f55f

View File

@ -2,6 +2,7 @@ import java.io.File
import java.util.Scanner
import kotlin.system.exitProcess
import org.jetbrains.letsPlot.*
import org.jetbrains.letsPlot.geom.geomBar
import org.jetbrains.letsPlot.intern.Plot
@ -9,8 +10,6 @@ val scanner = Scanner(System.`in`)
object StatisticBuilder {
val plot: Plot? = null
fun askAndExecuteSelfCommands() {
val text = getTextData() ?: return
@ -40,11 +39,21 @@ object StatisticBuilder {
}
private fun buildGraphic(textName: String, mapOfSentenceNumToItsSize: Map<Int, Int>) {
val plot: Plot =
ggplot(mapOfSentenceNumToItsSize) + ggsize(1000, 600) + geomBar { x = "sentence number"; y = "words count" }
}
private fun printStatisticsInConsole(textName: String, mapOfSentenceNumToItsSize: Map<Int, Int>) {
println("-".repeat(textName.length))
println("Text name: $textName")
println("-".repeat(textName.length))
println(
"Statistics[num of sentence: count of words in it]: ${
mapOfSentenceNumToItsSize.toList().joinToString("; ") { "${it.first}: ${it.second}" } }.")
println("-".repeat(textName.length))
println("Done!\n")
}
private fun getTextData(): TextData.Text? {
@ -93,7 +102,7 @@ object TextReader {
val name = readln()
println("Input a text content:")
var content: String = ""
var content = ""
readCycle@ while (true) {
val nextPart = scanner.next()
if (nextPart.isEmpty()) content += nextPart