From 87e744f55f80cf5b8fb10abd0a6e92258ddb82d0 Mon Sep 17 00:00:00 2001 From: ZhigalskiiIvan <671342i@gmail.com> Date: Fri, 24 Mar 2023 19:18:30 +0300 Subject: [PATCH] create output in console method --- src/main/kotlin/Main.kt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt index cff4efc..83978ee 100644 --- a/src/main/kotlin/Main.kt +++ b/src/main/kotlin/Main.kt @@ -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) { + val plot: Plot = + ggplot(mapOfSentenceNumToItsSize) + ggsize(1000, 600) + geomBar { x = "sentence number"; y = "words count" } + } private fun printStatisticsInConsole(textName: String, mapOfSentenceNumToItsSize: Map) { - + 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