Skip to content
Snippets Groups Projects
Commit 61253e95 authored by Joni Krebs's avatar Joni Krebs
Browse files

added generation of long text for already working facts

parent 297b8c0c
No related branches found
No related tags found
No related merge requests found
import java.nio.file.Files
import java.nio.file.Paths
val inputPathAnordnung = Paths.get("C:\\users\\jok3r\\domains\\anordnungen\\anordnungen.txt")
val inputPathAuftraege = Paths.get("C:\\users\\jok3r\\domains\\anordnungen\\N1CORDER.txt")
val inputPathAnordnung = Paths.get("J:\\domains\\orders\\anordnungen_21_02_08.txt")
val inputPathAuftraege = Paths.get("J:\\domains\\orders\\N1CORDER_21_02_08.txt")
val outputHTML = Paths.get("C:\\users\\jok3r\\domains\\anordnungen\\anordnung2auftrag.html")
val outputFolder = "C:\\users\\jok3r\\domains\\anordnungen\\training00\\"
......@@ -18,17 +18,15 @@ fun main() {
}
}.filterNotNull()
println()
// val counter = mutableMapOf<String, Double>()
// pairs.shuffled().subList(0,100).forEach {
// counter.putIfAbsent(it.second["CORDTITLE"]!!, 0.0)
// counter.computeIfPresent(it.second["CORDTITLE"]!!) { _, v -> v + 1}
// val content = it.first["CONTENT"]
// Files.writeString(Paths.get(outputFolder + it.first["Dokumentnummer"]!!.trimStart('0')+".txt"), content)
// }
// println(pairs.size)
// counter.forEach { (t, u) ->
// println("$t\t$u")
// }
val counter = mutableMapOf<String, Double>()
pairs.forEach {
counter.putIfAbsent(it.second["UPUSR"]!!, 0.0)
counter.computeIfPresent(it.second["UPUSR"]!!) { _, v -> v + 1}
}
println(pairs.size)
counter.map { it.key to it. value }.forEach { (t, u) ->
println("$t\t$u")
}
}
......
......@@ -28,25 +28,27 @@ object Extractor {
//TODO do something meaningful
val output = Output(
input.docid,
input.doctime,
modality,
anamnesis,
anamnesis,
question,
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
emptyList<Service>().toMutableList()
input.docid,
input.doctime,
modality,
anamnesis,
anamnesis,
question,
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
emptyList<Service>().toMutableList()
)
createLongText(output)
res.type("application/json; charset=utf-8")
return Gson().toJson(output)
}
......@@ -60,9 +62,9 @@ object Extractor {
private fun getModality(cas: CAS): String {
val tEntity = Types.getType(cas, Types.IEENTITY)
val owlid = cas.getAnnotationIndex(tEntity)
.sortedBy { it.begin }
.map { it.getFeatureValueAsString(tEntity.getFeatureByBaseName("owlid")) }
.firstOrNull()
.sortedBy { it.begin }
.map { it.getFeatureValueAsString(tEntity.getFeatureByBaseName("owlid")) }
.firstOrNull()
return when (owlid) {
"ModalitätCT" -> "Computer-Tomographie"
"Modalitätkonv. Röntgen" -> "konv. Röntgen"
......@@ -77,19 +79,27 @@ object Extractor {
val url = "http://localhost:$pythonPort/predict"
try {
val result = khttp.post(
url = url,
json = mapOf("order-text" to doctext),
timeout = 10.0
url = url,
json = mapOf("order-text" to doctext),
timeout = 10.0
)
if (result.statusCode == 200) {
val anamnesis = result.jsonObject["anamnesis"].toString()
val question = result.jsonObject["question"].toString()
return Pair(anamnesis,question)
return Pair(anamnesis, question)
}
return Pair("", "")
} catch (e: Exception) {
return Pair("", "")
}
}
private fun createLongText(output: Output) {
var text = ""
text += "Modalität: ${output.modality}\r\n"
text += "Diagnose/Anamnese: ${output.anamnesis}\r\n"
text += "Fragestellung: ${output.question}\r\n"
output.long_text = text
}
}
......@@ -22,6 +22,7 @@ data class Output (
val allergy_type_other: String,
val preferred_date: String,
val preferred_date_cycle: String,
var long_text: String,
val services: MutableList<Service>
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment