From 62ea2fc1b713c5ef6b94f232b77ef03a15b08d58 Mon Sep 17 00:00:00 2001 From: joethei Date: Sat, 13 Apr 2019 10:03:27 +0200 Subject: [PATCH] SPM-29: done --- .../de/hsel/spm/baudas/analysis/Analysis.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/main/java/de/hsel/spm/baudas/analysis/Analysis.java diff --git a/src/main/java/de/hsel/spm/baudas/analysis/Analysis.java b/src/main/java/de/hsel/spm/baudas/analysis/Analysis.java new file mode 100644 index 0000000..b8bc054 --- /dev/null +++ b/src/main/java/de/hsel/spm/baudas/analysis/Analysis.java @@ -0,0 +1,45 @@ +package de.hsel.spm.baudas.analysis; + +import org.jetbrains.annotations.Nullable; +import weka.core.Instances; +import weka.core.converters.CSVLoader; + +import java.io.File; +import java.io.IOException; + +/** + * base interface for analysis + * + * @author Johannes Theiner + * @version 0.1 + * @since 0.1 + * @param Type the chosen analysis returns as a result + */ +public interface Analysis { + + + /** + * loads data from csv file + * + * @param file File to analyze + * @return loaded data in weka format + */ + @Nullable + default Instances load(File file) { + CSVLoader loader = new CSVLoader(); + try { + loader.setSource(file); + return loader.getDataSet(); + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } + + /** + * result of the analysis + * + * @return result as T + */ + T getResult(); +} \ No newline at end of file