for (j in 0 until pdfReader.numberOfPages) {
extractedText += PdfTextExtractor.getTextFromPage(pdfReader, j + 1)
technologies.forEach { (key, values) ->
values.map {
if (extractedText.contains(it, ignoreCase = true)
|| extractedText.contains("${it}s", ignoreCase = true)
) {
occurrences[key] = occurrences.getOrDefault(key, 0) + 1
}
}
}
}
println(occurrences)
val person = extractedText.split(" ")[0].trim { it == ',' }
results[person] = occurrences
I would like to clear
occurrences
after I’m done with it so that I can load it again with new values after I insert it into
results[person]
but doing that is causing it to store an empty map into `results[person]`…
oday
09/30/2022, 1:00 PM
setting occurrnces to a new map solves this, but I want to clear it..
m
mkrussel
09/30/2022, 1:08 PM
Everything is references, so any changes you make to the object will change all references to it including what is in results.
So you need two instances. You can either replace occurrences with a new map or copy (