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

updated aries dependencies, added leistungen reader

parent 957e5f96
No related branches found
No related tags found
No related merge requests found
...@@ -53,16 +53,21 @@ ...@@ -53,16 +53,21 @@
<artifactId>khttp</artifactId> <artifactId>khttp</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.github.doyaaaaaken</groupId>
<artifactId>kotlin-csv-jvm</artifactId>
<version>0.15.2</version>
</dependency>
<dependency> <dependency>
<groupId>de.uniwue.aries</groupId> <groupId>de.uniwue.aries</groupId>
<artifactId>aries-ontology-model-io</artifactId> <artifactId>aries-ontology-model-io</artifactId>
<version>1.0.0</version> <version>1.1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>de.uniwue.aries</groupId> <groupId>de.uniwue.aries</groupId>
<artifactId>aries-algorithm</artifactId> <artifactId>aries-algorithm</artifactId>
<version>1.1.15</version> <version>1.3.0</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
......
import de.uniwue.aries.algorithm.ARIESAlgorithm import de.uniwue.aries.algorithm.ARIESAlgorithm
import de.uniwue.aries.ontology.io.ExcelFileReader import de.uniwue.aries.ontology.io.excel.ExcelFileReader
import de.uniwue.aries.uima.types.Types import de.uniwue.aries.uima.types.Types
import org.apache.uima.cas.text.AnnotationFS
import org.apache.uima.util.CasCreationUtils import org.apache.uima.util.CasCreationUtils
fun main() { fun main() {
...@@ -10,9 +11,9 @@ fun main() { ...@@ -10,9 +11,9 @@ fun main() {
val system = pairs.map { it.first["CONTENT"] }.map { val system = pairs.map { it.first["CONTENT"] }.map {
val cas = CasCreationUtils.createCas(Types.getTypeSystem(), null, null) val cas = CasCreationUtils.createCas(Types.getTypeSystem(), null, null)
cas.documentText = it cas.documentText = it
algo.extract(cas, ontology) algo.extract(cas, ontology, "")
val tEntity = Types.getType(cas, Types.IEENTITY) val tEntity = Types.getType(cas, Types.IEENTITY)
val owlid = cas.getAnnotationIndex(tEntity) val owlid = cas.getAnnotationIndex<AnnotationFS>(tEntity)
.sortedBy { it.begin } .sortedBy { it.begin }
.map { it.getFeatureValueAsString(tEntity.getFeatureByBaseName("owlid")) } .map { it.getFeatureValueAsString(tEntity.getFeatureByBaseName("owlid")) }
.firstOrNull() .firstOrNull()
......
import com.github.doyaaaaaken.kotlincsv.dsl.csvReader
import java.io.File
import java.lang.IllegalArgumentException
class LeistungReader {
fun read(csvFileName: String): List<Map<String, String>> {
return csvReader().readAllWithHeader(File(csvFileName))
}
}
fun filterByModality(leistungen: List<Map<String, String>>, modality: String): List<Map<String, String>> {
val modalityCode = when(modality) {
"konv. Röntgen" -> "RKR"
"Computer-Tomographie" -> "RCT"
"MR - Tomographie Rö" -> "RMR"
"Ultraschall" -> "RUS"
"Durchleuchtung" -> "RDL"
else -> {
throw IllegalArgumentException("unknown modality")
}
}
return leistungen.filter { it["id"]!!.startsWith(modalityCode) }
}
fun filterByLocalizationOrModifier(leistungen: List<Map<String, String>>, localizationOrModifier: String): List<Map<String, String>> {
return leistungen.filter{ it["description"]!!.contains(localizationOrModifier)}
}
fun main() {
val leistungen = LeistungReader().read("C:\\users\\jok3r\\domains\\anordnungen\\radio_hierarchy.csv")
val requestable = leistungen.filter { it["requestable"] == "True" }
var filtered = filterByModality(requestable, "konv. Röntgen")
listOf<String>("Handgelenk", "2 Ebenen").forEach {
filtered = filterByLocalizationOrModifier(filtered, it)
}
var res = filtered.minBy { it["description"]!!.length }
println()
}
\ No newline at end of file
...@@ -2,15 +2,15 @@ package de.dzptm.server ...@@ -2,15 +2,15 @@ package de.dzptm.server
import com.google.gson.Gson import com.google.gson.Gson
import de.uniwue.aries.algorithm.ARIESAlgorithm import de.uniwue.aries.algorithm.ARIESAlgorithm
import de.uniwue.aries.ontology.io.ExcelFileReader import de.uniwue.aries.ontology.io.excel.ExcelFileReader
import de.uniwue.aries.uima.types.Types import de.uniwue.aries.uima.types.Types
import org.apache.uima.cas.CAS import org.apache.uima.cas.CAS
import org.apache.uima.cas.text.AnnotationFS
import org.apache.uima.util.CasCreationUtils import org.apache.uima.util.CasCreationUtils
import org.json.JSONArray import org.json.JSONArray
import org.json.JSONObject import org.json.JSONObject
import spark.Request import spark.Request
import spark.Response import spark.Response
import java.lang.NumberFormatException
import java.time.LocalDate import java.time.LocalDate
import java.time.LocalDateTime import java.time.LocalDateTime
import java.time.LocalTime import java.time.LocalTime
...@@ -93,7 +93,7 @@ object Extractor { ...@@ -93,7 +93,7 @@ object Extractor {
} }
val type = Types.getType(cas, Types.IEENTITY) val type = Types.getType(cas, Types.IEENTITY)
val annotation = cas.getAnnotationIndex(type) val annotation = cas.getAnnotationIndex<AnnotationFS>(type)
.filter { it.getFeatureValueAsString(type.getFeatureByBaseName("owlid")).contains("Date|||") } .filter { it.getFeatureValueAsString(type.getFeatureByBaseName("owlid")).contains("Date|||") }
.sortedBy { it.begin }.last() .sortedBy { it.begin }.last()
val format = annotation.getFeatureValueAsString(type.getFeatureByBaseName("owlid")).substringAfterLast("|") val format = annotation.getFeatureValueAsString(type.getFeatureByBaseName("owlid")).substringAfterLast("|")
...@@ -135,7 +135,7 @@ object Extractor { ...@@ -135,7 +135,7 @@ object Extractor {
private fun applyARIES(cas: CAS) { private fun applyARIES(cas: CAS) {
val ontology = ExcelFileReader.read(ClassLoader.getSystemResourceAsStream("KlinischerAuftrag20210608.xlsx")) val ontology = ExcelFileReader.read(ClassLoader.getSystemResourceAsStream("KlinischerAuftrag20210608.xlsx"))
val algo = ARIESAlgorithm() val algo = ARIESAlgorithm()
algo.extract(cas, ontology) algo.extract(cas, ontology, "")
} }
private fun convertProbs(json: JSONArray): List<List<Double>> { private fun convertProbs(json: JSONArray): List<List<Double>> {
...@@ -165,7 +165,7 @@ object Extractor { ...@@ -165,7 +165,7 @@ object Extractor {
private fun getModality(cas: CAS): String { private fun getModality(cas: CAS): String {
val tEntity = Types.getType(cas, Types.IEENTITY) val tEntity = Types.getType(cas, Types.IEENTITY)
val owlid = cas.getAnnotationIndex(tEntity) val owlid = cas.getAnnotationIndex<AnnotationFS>(tEntity)
.sortedBy { it.begin } .sortedBy { it.begin }
.map { it.getFeatureValueAsString(tEntity.getFeatureByBaseName("owlid")) } .map { it.getFeatureValueAsString(tEntity.getFeatureByBaseName("owlid")) }
.firstOrNull { .firstOrNull {
...@@ -188,7 +188,7 @@ object Extractor { ...@@ -188,7 +188,7 @@ object Extractor {
private fun getSAPEnumValueForAttributeID(cas: CAS, attributeID: String): String { private fun getSAPEnumValueForAttributeID(cas: CAS, attributeID: String): String {
val tEntity = Types.getType(cas, Types.IEENTITY) val tEntity = Types.getType(cas, Types.IEENTITY)
val owlids = cas.getAnnotationIndex(tEntity) val owlids = cas.getAnnotationIndex<AnnotationFS>(tEntity)
.sortedBy { it.begin } .sortedBy { it.begin }
.map { it.getFeatureValueAsString(tEntity.getFeatureByBaseName("owlid")) } .map { it.getFeatureValueAsString(tEntity.getFeatureByBaseName("owlid")) }
.filter { it.contains(attributeID) } .filter { it.contains(attributeID) }
......
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