diff --git a/src/main/java/de/hsel/spm/baudas/analysis/WeekOverview.java b/src/main/java/de/hsel/spm/baudas/analysis/WeekOverview.java new file mode 100644 index 0000000..081f4f9 --- /dev/null +++ b/src/main/java/de/hsel/spm/baudas/analysis/WeekOverview.java @@ -0,0 +1,73 @@ +package de.hsel.spm.baudas.analysis; + +import org.jetbrains.annotations.Nullable; +import weka.core.Instance; +import weka.core.Instances; +import weka.filters.Filter; +import weka.filters.unsupervised.attribute.Remove; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; + +/** + * Week Overview Analysis + * + * @author Julian Hinxlage + * @version 0.1 + * @since 0.1 + **/ +public class WeekOverview implements Analysis> { + + private Instances instances; + private Map result; + + public WeekOverview(File file) { + result = new HashMap(); + instances = load(file); + } + + @Override + public Map getResult() { + + int[] keepIndexes = new int[]{5, 10}; + int dayIndex = 0; + int amountIndex = 1; + + + try { + //Remove all other attributes + Remove remove = new Remove(); + remove.setAttributeIndicesArray(keepIndexes); + remove.setInvertSelection(true); + remove.setInputFormat(instances); + instances = Filter.useFilter(instances, remove); + } catch (Exception ex) { + ex.printStackTrace(); + } + + + for (int i = 0; i < instances.attribute(dayIndex).numValues(); i++) { + String day = instances.attribute(dayIndex).value(i); + + System.out.println(day); + + + for (int j = 0; j < instances.attribute(amountIndex).numValues(); j++) { + String amount = instances.attribute(amountIndex).value(j); + + System.out.println(amount); + + int x = Integer.parseInt(amount); + + if(!result.containsKey(day)){ + result.put(day,0); + } + result.put(day,result.get(day) + x); + + } + } + + return result; + } +} diff --git a/src/test/java/de/hsel/spm/baudas/WeekOverviewTest.java b/src/test/java/de/hsel/spm/baudas/WeekOverviewTest.java new file mode 100644 index 0000000..9e285f5 --- /dev/null +++ b/src/test/java/de/hsel/spm/baudas/WeekOverviewTest.java @@ -0,0 +1,30 @@ +package de.hsel.spm.baudas; + +import de.hsel.spm.baudas.analysis.WeekOverview; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.util.Map; + + +/** + * Week Overview Analysis Test + * + * @author Julian Hinxlage + * @version 0.1 + * @since 0.1 + **/ +public class WeekOverviewTest { + + @Test + public void test(){ + WeekOverview overview = new WeekOverview(new File(getClass().getClassLoader().getResource("kd100.csv").getFile())); + + Map result = overview.getResult(); + + for(Map.Entry i : result.entrySet()){ + System.out.println(i.getKey() + " = " + i.getValue()); + } + + } +} diff --git a/target/classes/META-INF/bauDas-kundenkarten.kotlin_module b/target/classes/META-INF/bauDas-kundenkarten.kotlin_module new file mode 100644 index 0000000..8fb6019 Binary files /dev/null and b/target/classes/META-INF/bauDas-kundenkarten.kotlin_module differ diff --git a/target/classes/de/hsel/spm/baudas/WekaBeispiel.class b/target/classes/de/hsel/spm/baudas/WekaBeispiel.class index 9b51366..f5ed3d5 100644 Binary files a/target/classes/de/hsel/spm/baudas/WekaBeispiel.class and b/target/classes/de/hsel/spm/baudas/WekaBeispiel.class differ diff --git a/target/classes/de/hsel/spm/baudas/analysis/Analysis.class b/target/classes/de/hsel/spm/baudas/analysis/Analysis.class new file mode 100644 index 0000000..af682a2 Binary files /dev/null and b/target/classes/de/hsel/spm/baudas/analysis/Analysis.class differ diff --git a/target/classes/de/hsel/spm/baudas/analysis/WeekOverview.class b/target/classes/de/hsel/spm/baudas/analysis/WeekOverview.class new file mode 100644 index 0000000..161304a Binary files /dev/null and b/target/classes/de/hsel/spm/baudas/analysis/WeekOverview.class differ diff --git a/target/test-classes/META-INF/bauDas-kundenkarten.kotlin_module b/target/test-classes/META-INF/bauDas-kundenkarten.kotlin_module new file mode 100644 index 0000000..8fb6019 Binary files /dev/null and b/target/test-classes/META-INF/bauDas-kundenkarten.kotlin_module differ diff --git a/target/test-classes/de/hsel/spm/baudas/WeekOverviewTest.class b/target/test-classes/de/hsel/spm/baudas/WeekOverviewTest.class new file mode 100644 index 0000000..c8b72a6 Binary files /dev/null and b/target/test-classes/de/hsel/spm/baudas/WeekOverviewTest.class differ