summaryrefslogtreecommitdiff
path: root/src/main/Analyzor.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/Analyzor.java')
-rw-r--r--src/main/Analyzor.java22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/main/Analyzor.java b/src/main/Analyzor.java
index 73acd64..bc81440 100644
--- a/src/main/Analyzor.java
+++ b/src/main/Analyzor.java
@@ -11,7 +11,23 @@ package main;
* @author s123188
*/
public class Analyzor {
- //TODO: make botfilter
-
- //TODO: make sentiment analysis
+ // test is the tweet text you are going to analyze
+ String[] testlist = test.split("\\s+"); // text splitted into separate words
+ double positiverate = 0; // positive rating
+
+ for (String word : testlist) { // Rate the text with each word with uni
+ if (unimap.containsKey(word)) {
+ positiverate += unimap.get(word);
+ }
+ }
+
+ for (int i = 0; i < testlist.length-1; i++) { // Rate text with pair words with bi
+ String pair = testlist[i] + " " + testlist[i+1];
+ if (bimap.containsKey(pair)) {
+ positiverate += bimap.get(pair);
+ }
+ }
+
+ System.out.println(test + ": " + (int) (positiverate * 10));
+ // print rate as int. Alter to return if you like
}