From 2207f300d6025b376b461fb69f5e3c88d1992b5f Mon Sep 17 00:00:00 2001 From: Thomas Breil Date: Thu, 22 Feb 2024 10:55:42 +0100 Subject: [PATCH] Update parsed map to lowercase --- src/main/kotlin/main/parser.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/main/parser.kt b/src/main/kotlin/main/parser.kt index 34632d2..1edbf6a 100644 --- a/src/main/kotlin/main/parser.kt +++ b/src/main/kotlin/main/parser.kt @@ -54,7 +54,7 @@ fun parserJS(fileName : String) : MutableMap { val regex = "[^a-zA-Z^éà]".toRegex() val array = mutableListOf() - val line = delStrings(takeOnlyJs(fileName)).replace(regex, " ").lowercase() + val line = delStrings(takeOnlyJs(fileName)).replace(regex, " ") line.split(delimiter1).forEach { if (it != "") { @@ -62,8 +62,9 @@ fun parserJS(fileName : String) : MutableMap { } } val map = jsWords(array.groupingBy { it }.eachCount()) + val lowerMap = map.mapKeys { it.key.lowercase() } - var sortedMap = map.toList().take(10).sortedBy { (_, value) -> value }.toMap() + var sortedMap = lowerMap.toList().take(10).sortedBy { (_, value) -> value }.toMap() sortedMap.forEach { (t, u) -> println("$t : $u") } // affiche le nombre d'occurence de chaque mot sortedMap = sortedMap.toMutableMap() return sortedMap @@ -106,5 +107,6 @@ fun directoryParse(directory : String) : MutableMap { } } - return map + val lowerMap = map.mapKeys { it.key.lowercase() } + return lowerMap.toMutableMap() }