-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding the project code in the repository.
- Loading branch information
0 parents
commit 4343c5d
Showing
1,489 changed files
with
436,914 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
myenv/ |
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+476 Bytes
.metadata/.plugins/com.amazonaws.eclipse.core/regions/flags/asia_pacific.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+689 Bytes
.metadata/.plugins/com.amazonaws.eclipse.core/regions/flags/australia.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+393 Bytes
.metadata/.plugins/com.amazonaws.eclipse.core/regions/flags/brazil.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+407 Bytes
.metadata/.plugins/com.amazonaws.eclipse.core/regions/flags/canada.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+546 Bytes
.metadata/.plugins/com.amazonaws.eclipse.core/regions/flags/china.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+503 Bytes
.metadata/.plugins/com.amazonaws.eclipse.core/regions/flags/flag_india.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.75 KB
.metadata/.plugins/com.amazonaws.eclipse.core/regions/flags/germany.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.74 KB
.metadata/.plugins/com.amazonaws.eclipse.core/regions/flags/ireland.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.05 KB
.metadata/.plugins/com.amazonaws.eclipse.core/regions/flags/japan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.15 KB
.metadata/.plugins/com.amazonaws.eclipse.core/regions/flags/south_korea.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+476 Bytes
.metadata/.plugins/com.amazonaws.eclipse.core/regions/flags/usa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
538 changes: 538 additions & 0 deletions
538
.metadata/.plugins/com.amazonaws.eclipse.core/regions/regions.xml
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+14.9 KB
.metadata/.plugins/com.google.appengine.eclipse.core/appengine-sdk-proxy.jar
Binary file not shown.
10 changes: 10 additions & 0 deletions
10
.metadata/.plugins/org.eclipse.core.resources/.history/0/807fdd968ad100171204bfc68571734f
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name := """DICTeam8""" | ||
organization := "com.example" | ||
|
||
version := "1.0-SNAPSHOT" | ||
|
||
lazy val root = (project in file(".")).enablePlugins(PlayJava) | ||
|
||
scalaVersion := "2.12.2" | ||
|
||
libraryDependencies += guice |
300 changes: 300 additions & 0 deletions
300
.metadata/.plugins/org.eclipse.core.resources/.history/0/b0090f66cad100171204bfc68571734f
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,300 @@ | ||
package controllers; | ||
|
||
import play.libs.Json; | ||
import play.mvc.*; | ||
|
||
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; | ||
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder; | ||
import com.amazonaws.services.dynamodbv2.model.AttributeDefinition; | ||
import com.amazonaws.services.dynamodbv2.model.AttributeValue; | ||
import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughputDescription; | ||
import com.amazonaws.services.dynamodbv2.model.ScanRequest; | ||
import com.amazonaws.services.dynamodbv2.model.ScanResult; | ||
import com.amazonaws.services.dynamodbv2.model.TableDescription; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
|
||
import java.text.DateFormat; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.amazonaws.AmazonServiceException; | ||
import com.amazonaws.regions.Regions; | ||
|
||
|
||
/** | ||
* This controller contains an action to handle HTTP requests | ||
* to the application's home page. | ||
*/ | ||
public class HomeController extends Controller { | ||
|
||
/** | ||
* An action that renders an HTML page with a welcome message. | ||
* The configuration in the <code>routes</code> file means that | ||
* this method will be called when the application receives a | ||
* <code>GET</code> request with a path of <code>/</code>. | ||
*/ | ||
AmazonDynamoDB ddb = AmazonDynamoDBClientBuilder.standard() | ||
.withRegion(Regions.US_EAST_1) | ||
.build(); | ||
String table_name = "live_twitter_dic8"; | ||
public Result index() { | ||
int countRecords =0; | ||
int countReplies = 0; | ||
Map<String,Integer> keywordCount = new HashMap<>(); | ||
try { | ||
// TableDescription table_info = | ||
// ddb.describeTable(table_name).getTable(); | ||
ScanRequest scanRequest = new ScanRequest() | ||
.withTableName(table_name); | ||
Map<String,AttributeValue> lastKey = null; | ||
|
||
do { | ||
|
||
ScanResult scanResult = ddb.scan(scanRequest); | ||
|
||
List<Map<String,AttributeValue>> results = scanResult.getItems(); | ||
countRecords+=results.size(); | ||
results.forEach(r->{ | ||
System.out.println(r); | ||
}); | ||
System.out.println("Count Records: "+countRecords); | ||
for(Map<String,AttributeValue> mp : results){ | ||
//for(String s:mp.keySet()){ | ||
try{ | ||
countReplies = mp.get("replies").getN()==null?-99:Integer.parseInt(mp.get("replies").getN()); | ||
} | ||
catch(Exception e){ | ||
countReplies = -99; | ||
} | ||
if(keywordCount.containsKey(mp.get("key_word"))){ | ||
keywordCount.put(mp.get("key_word").getS(), keywordCount.get(mp.get("key_word"))+ countReplies); | ||
} | ||
else{ | ||
keywordCount.put(mp.get("key_word").getS(),countReplies); | ||
} | ||
//} | ||
} | ||
//results.forEach(r->System.out.println(r.get("key_word").getS())); | ||
lastKey = scanResult.getLastEvaluatedKey(); | ||
scanRequest.setExclusiveStartKey(lastKey); | ||
} while (lastKey!=null); | ||
} catch (AmazonServiceException e) { | ||
System.err.println(e.getErrorMessage()); | ||
System.exit(1); | ||
} | ||
System.out.println("----------------------Scanned Results-------------------------"); | ||
for(String s:keywordCount.keySet()){ | ||
System.out.println(s+" : " + keywordCount.get(s)); | ||
} | ||
return ok(views.html.index.render()); | ||
} | ||
public Result hourly() { | ||
ObjectNode responseJson = Json.newObject(); | ||
Map<String,Integer> keywordCount = new HashMap<>(); | ||
try{ | ||
Map<String,String> expressionAttributesNames = new HashMap<>(); | ||
expressionAttributesNames.put("#key_datetime","key_datetime"); | ||
Map<String,AttributeValue> expressionAttributeValues = new HashMap<>(); | ||
expressionAttributeValues.put(":from",new AttributeValue().withS("2017-11-24-00")); | ||
expressionAttributeValues.put(":to",new AttributeValue().withS("2017-11-24-23")); | ||
ScanRequest scanRequest = new ScanRequest() | ||
.withTableName("combinedTable_hourly") | ||
.withFilterExpression("#key_datetime BETWEEN :from AND :to ") | ||
.withExpressionAttributeNames(expressionAttributesNames) | ||
.withExpressionAttributeValues(expressionAttributeValues); | ||
Map<String,AttributeValue> lastKey = null; | ||
int countReplies = 0; | ||
do { | ||
|
||
ScanResult scanResult = ddb.scan(scanRequest); | ||
|
||
List<Map<String,AttributeValue>> results = scanResult.getItems(); | ||
int countRecords = results.size(); | ||
results.forEach(r->{ | ||
System.out.println(r); | ||
}); | ||
for(Map<String,AttributeValue> mp : results){ | ||
try{ | ||
countReplies = mp.get("score").getN()==null?-99:Integer.parseInt(mp.get("score").getN()); | ||
} | ||
catch(Exception e){ | ||
countReplies = -99; | ||
} | ||
if(keywordCount.containsKey(mp.get("key_word"))){ | ||
keywordCount.put(mp.get("key_word").getS(), keywordCount.get(mp.get("key_word"))+ countReplies); | ||
} | ||
else{ | ||
keywordCount.put(mp.get("key_word").getS(),countReplies); | ||
} | ||
//} | ||
|
||
} | ||
lastKey = scanResult.getLastEvaluatedKey(); | ||
scanRequest.setExclusiveStartKey(lastKey); | ||
} while (lastKey!=null); | ||
} catch (AmazonServiceException e) { | ||
System.err.println(e.getErrorMessage()); | ||
System.exit(1); | ||
} | ||
for(String s:keywordCount.keySet()){ | ||
responseJson.put(s,keywordCount.get(s)); | ||
} | ||
return ok(responseJson); | ||
} | ||
public Result minute() { | ||
ObjectNode responseJson = Json.newObject(); | ||
Map<String,Integer> keywordCount = new HashMap<>(); | ||
try{ | ||
ScanRequest scanRequest = new ScanRequest() | ||
.withTableName("combinedTable"); | ||
Map<String,AttributeValue> lastKey = null; | ||
int countReplies = 0; | ||
do { | ||
|
||
ScanResult scanResult = ddb.scan(scanRequest); | ||
|
||
List<Map<String,AttributeValue>> results = scanResult.getItems(); | ||
int countRecords = results.size(); | ||
results.forEach(r->{ | ||
System.out.println(r); | ||
}); | ||
for(Map<String,AttributeValue> mp : results){ | ||
try{ | ||
countReplies = mp.get("score").getN()==null?-99:Integer.parseInt(mp.get("score").getN()); | ||
if(countReplies==0){ | ||
countReplies=1; | ||
} | ||
} | ||
catch(Exception e){ | ||
countReplies = -99; | ||
} | ||
if(keywordCount.containsKey(mp.get("key_word"))){ | ||
keywordCount.put(mp.get("key_word").getS(), keywordCount.get(mp.get("key_word"))+ countReplies); | ||
} | ||
else{ | ||
keywordCount.put(mp.get("key_word").getS(),countReplies); | ||
} | ||
//} | ||
|
||
} | ||
lastKey = scanResult.getLastEvaluatedKey(); | ||
scanRequest.setExclusiveStartKey(lastKey); | ||
} while (lastKey!=null); | ||
} catch (AmazonServiceException e) { | ||
System.err.println(e.getErrorMessage()); | ||
System.exit(1); | ||
} | ||
for(String s:keywordCount.keySet()){ | ||
responseJson.put(s,keywordCount.get(s)); | ||
} | ||
return ok(responseJson); | ||
|
||
} | ||
public Result realTime(){ | ||
ObjectNode responseJson = Json.newObject(); | ||
DateFormat dateHourFormat = new SimpleDateFormat("yyyy-MM-dd-HH"); | ||
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); | ||
Date date = new Date(); | ||
String hour = dateHourFormat.format(date); | ||
String starthour = dateFormat.format(date)+"-00"; | ||
System.out.println(hour); | ||
System.out.println(starthour); | ||
//2016/11/16 12:08:43 | ||
Map<String,Integer> keywordCount = new HashMap<>(); | ||
try{ | ||
Map<String,String> expressionAttributesNames = new HashMap<>(); | ||
expressionAttributesNames.put("#key_datetime","key_datetime"); | ||
Map<String,AttributeValue> expressionAttributeValues = new HashMap<>(); | ||
expressionAttributeValues.put(":from",new AttributeValue().withS(starthour)); | ||
expressionAttributeValues.put(":to",new AttributeValue().withS(hour)); | ||
ScanRequest scanRequest = new ScanRequest() | ||
.withTableName("combinedTable_hourly") | ||
.withFilterExpression("#key_datetime BETWEEN :from AND :to ") | ||
.withExpressionAttributeNames(expressionAttributesNames) | ||
.withExpressionAttributeValues(expressionAttributeValues); | ||
Map<String,AttributeValue> lastKey = null; | ||
int countReplies = 0; | ||
do { | ||
|
||
ScanResult scanResult = ddb.scan(scanRequest); | ||
|
||
List<Map<String,AttributeValue>> results = scanResult.getItems(); | ||
//int countRecords = results.size(); | ||
results.forEach(r->{ | ||
System.out.println(r); | ||
}); | ||
for(Map<String,AttributeValue> mp : results){ | ||
try{ | ||
countReplies = mp.get("score").getN()==null?-99:Integer.parseInt(mp.get("score").getN()); | ||
} | ||
catch(Exception e){ | ||
countReplies = -99; | ||
} | ||
if(keywordCount.containsKey(mp.get("key_word"))){ | ||
keywordCount.put(mp.get("key_word").getS(), keywordCount.get(mp.get("key_word"))+ countReplies); | ||
} | ||
else{ | ||
keywordCount.put(mp.get("key_word").getS(),countReplies); | ||
} | ||
//} | ||
|
||
} | ||
lastKey = scanResult.getLastEvaluatedKey(); | ||
scanRequest.setExclusiveStartKey(lastKey); | ||
} while (lastKey!=null); | ||
} catch (AmazonServiceException e) { | ||
System.err.println(e.getErrorMessage()); | ||
System.exit(1); | ||
} | ||
try{ | ||
ScanRequest scanRequest = new ScanRequest() | ||
.withTableName("combinedTable"); | ||
Map<String,AttributeValue> lastKey = null; | ||
int countReplies = 0; | ||
do { | ||
|
||
ScanResult scanResult = ddb.scan(scanRequest); | ||
|
||
List<Map<String,AttributeValue>> results = scanResult.getItems(); | ||
//int countRecords = results.size(); | ||
results.forEach(r->{ | ||
System.out.println(r); | ||
}); | ||
for(Map<String,AttributeValue> mp : results){ | ||
try{ | ||
countReplies = mp.get("score").getN()==null?-99:Integer.parseInt(mp.get("score").getN()); | ||
if(countReplies==0){ | ||
countReplies=1; | ||
} | ||
} | ||
catch(Exception e){ | ||
countReplies = -99; | ||
} | ||
if(keywordCount.containsKey(mp.get("key_word"))){ | ||
responseJson.put(mp.get("key_word").getS(),"Twice"); | ||
keywordCount.put(mp.get("key_word").getS(), keywordCount.get(mp.get("key_word"))+ countReplies); | ||
} | ||
else{ | ||
keywordCount.put(mp.get("key_word").getS(),countReplies); | ||
} | ||
//} | ||
|
||
} | ||
lastKey = scanResult.getLastEvaluatedKey(); | ||
scanRequest.setExclusiveStartKey(lastKey); | ||
} while (lastKey!=null); | ||
} catch (AmazonServiceException e) { | ||
System.err.println(e.getErrorMessage()); | ||
System.exit(1); | ||
} | ||
for(String s:keywordCount.keySet()){ | ||
responseJson.put(s,keywordCount.get(s)); | ||
} | ||
return ok(responseJson); | ||
|
||
|
||
} | ||
} |
Oops, something went wrong.