| 6 | // loads a csv file for the images in a directory |
| 7 | |
| 8 | class SimpleAnalysis(val fn: String) { |
| 9 | val data = mutableListOf<List<Float>>() |
| 10 | |
| 11 | init { |
| 12 | val lines = Files.readAllLines(File(fn).toPath()) |
| 13 | for (s in lines) { |
| 14 | val pieces = s.split(",") |
| 15 | data.add(pieces.map { it.toFloat() }.toList()) |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | fun map(x: java.util.function.Function<List<Float>, Number?>): List<Int> { |
| 20 | return data.mapIndexed { i, d -> i to x.apply(d) }.filter { it.second != null }.sortedBy { it.second!!.toDouble() }.map { it.first } |
| 21 | } |
| 22 | } |
no test coverage detected