aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/org
diff options
context:
space:
mode:
authorSize432015-05-19 14:18:28 +0200
committerSize432015-05-19 14:18:28 +0200
commit2ae48bd768186a1b35e6f4c896a42f0cebe4765c (patch)
treee0a2a6bcdcb76b6c7acca027bf45f1f6146f9980 /app/src/main/java/org
parentMerge branch 'master' of https://github.com/camilstaps/RSSin (diff)
commented things
Diffstat (limited to 'app/src/main/java/org')
-rwxr-xr-xapp/src/main/java/org/rssin/neurons/FeedSorter.java114
1 files changed, 58 insertions, 56 deletions
diff --git a/app/src/main/java/org/rssin/neurons/FeedSorter.java b/app/src/main/java/org/rssin/neurons/FeedSorter.java
index fee6f4d..43e26c0 100755
--- a/app/src/main/java/org/rssin/neurons/FeedSorter.java
+++ b/app/src/main/java/org/rssin/neurons/FeedSorter.java
@@ -1,6 +1,8 @@
package org.rssin.neurons;
+import java.io.IOException;
import java.util.Calendar;
+import java.util.Hashtable;
import java.util.TimeZone;
/**
@@ -12,9 +14,9 @@ public class FeedSorter {
private int[] isNthMonthInput = new int[12];
private int[] isNthWeekDayInput = new int[7];
private int isMorning, isAfternoon, isEvening, isNight;
- private Hashtable<String, int> categoryInputs = new Hashtable<String, int>();
- private Hashtable<String, int> wordInputs = new Hashtable<String, int>();
- private Hashtable<String, int> feedSourceInputs = new Hashtable<String, int>();
+ private Hashtable<String, Integer> categoryInputs = new Hashtable<String, Integer>();
+ private Hashtable<String, Integer> wordInputs = new Hashtable<String, Integer>();
+ private Hashtable<String, Integer> feedSourceInputs = new Hashtable<String, Integer>();
public FeedSorter() {
//TODO: Load Neural Network
@@ -38,58 +40,58 @@ public class FeedSorter {
isNight = nn.addInput();
}
- private PredictionInterface getPrediction(FeedItem item) {
- double[] inputs = new double[nn.getInputCount()];
+// private PredictionInterface getPrediction(FeedItem item) {
+// double[] inputs = new double[nn.getInputCount()];
+//
+// //Initialize all inputs to -1 / false
+// for(int i = 0; i < inputs.length; i++)
+// {
+// inputs[i] = -1;
+// }
+//
+// //Set month
+// Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+// for(int i = 0; i < isNthMonthInput.length; i++)
+// {
+// if(cal.get(Calendar.MONTH) - cal.getMinimum(Calendar.MONTH) == i)
+// {
+// inputs[isNthMonthInput[i]] = 1;
+// }
+// }
+//
+// //Set weekday
+// for(int i = 0; i < isNthWeekDayInput.length; i++)
+// {
+// if(cal.get(Calendar.DAY_OF_WEEK) - cal.getMinimum(Calendar.DAY_OF_WEEK) == i)
+// {
+// inputs[isNthMonthInput[i]] = 1;
+// }
+// }
+//
+// //Set day
+// int hourOfDay = cal.get(Calendar.HOUR_OF_DAY);
+// if(hourOfDay > 6 && hourOfDay < 12)
+// {
+// inputs[isMorning] = 1;
+// }else if(hourOfDay >= 12 && hourOfDay <= 6)
+// {
+// inputs[isAfternoon] = 1;
+// }else if(hourOfDay >= 6 && hourOfDay < 23)
+// {
+// inputs[isEvening] = 1;
+// }else if(hourOfDay >= 23 || hourOfDay <= 6)
+// {
+// inputs[isNight] = 1;
+// }
+//
+// //TODO: source, category, title, text, etc of FeedItems
+//
+// return nn.computeOutput(inputs);
+// }
- //Initialize all inputs to -1 / false
- for(int i = 0; i < inputs.length; i++)
- {
- inputs[i] = -1;
- }
-
- //Set month
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- for(int i = 0; i < isNthMonthInput.length; i++)
- {
- if(cal.get(Calendar.MONTH) - cal.getMinimum(Calendar.MONTH) == i)
- {
- inputs[isNthMonthInput[i]] = 1;
- }
- }
-
- //Set weekday
- for(int i = 0; i < isNthWeekDayInput.length; i++)
- {
- if(cal.get(Calendar.DAY_OF_WEEK) - cal.getMinimum(Calendar.DAY_OF_WEEK) == i)
- {
- inputs[isNthMonthInput[i]] = 1;
- }
- }
-
- //Set day
- int hourOfDay = cal.get(Calendar.HOUR_OF_DAY);
- if(hourOfDay > 6 && hourOfDay < 12)
- {
- inputs[isMorning] = 1;
- }else if(hourOfDay >= 12 && hourOfDay <= 6)
- {
- inputs[isAfternoon] = 1;
- }else if(hourOfDay >= 6 && hourOfDay < 23)
- {
- inputs[isEvening] = 1;
- }else if(hourOfDay >= 23 || hourOfDay <= 6)
- {
- inputs[isNight] = 1;
- }
-
- //TODO: source, category, title, text, etc of FeedItems
-
- return nn.computeOutput(inputs);
- }
-
- public List<FeedItem> sortItems(List<FeedItem> items) {
- // Sort list based on something like date + nn.computeOutput() * DAY.
- throw new NotImplementedException();
- return items;
- }
+// public List<FeedItem> sortItems(List<FeedItem> items) {
+// // Sort list based on something like date + nn.computeOutput() * DAY.
+// throw new NotImplementedException();
+// return items;
+// }
}