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() }