Update parsed map to lowercase

main
Thomas Breil 2024-02-22 10:55:42 +01:00
parent 61e3f39705
commit 2207f300d6
1 changed files with 5 additions and 3 deletions

View File

@ -54,7 +54,7 @@ fun parserJS(fileName : String) : MutableMap<String, Int> {
val regex = "[^a-zA-Z^éà]".toRegex()
val array = mutableListOf<String>()
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<String, Int> {
}
}
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<String, Int> {
}
}
return map
val lowerMap = map.mapKeys { it.key.lowercase() }
return lowerMap.toMutableMap()
}