summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-06-11 11:11:00 +0200
committerPeter Wu <peter@lekensteyn.nl>2014-06-11 11:11:00 +0200
commit8a7d2e7fbd2b9b5a2a365431f000c5c1a3d6efe5 (patch)
tree93be73ba062acab1e55bc76ee6220d88aeab4b95
parente14c671f3cbb56a08d765bd992e4cf774a0d1353 (diff)
downloadGoldfarmer-8a7d2e7fbd2b9b5a2a365431f000c5c1a3d6efe5.tar.gz
Change to use 'RESET' instead of boolean
Also make selection query smaller
-rw-r--r--src/main/Analyzor.java2
-rw-r--r--src/main/FarmShell.java32
2 files changed, 11 insertions, 23 deletions
diff --git a/src/main/Analyzor.java b/src/main/Analyzor.java
index 810fc4d..2f6e4b5 100644
--- a/src/main/Analyzor.java
+++ b/src/main/Analyzor.java
@@ -266,7 +266,7 @@ public class Analyzor {
System.out.println("Obtaining all selected entries in tweet.");
if (queryText.isEmpty()) {
- query("select * from tweet");
+ query("SELECT tweetid, text FROM tweet");
} else {
query(queryText);
}
diff --git a/src/main/FarmShell.java b/src/main/FarmShell.java
index 766e652..525d342 100644
--- a/src/main/FarmShell.java
+++ b/src/main/FarmShell.java
@@ -147,31 +147,19 @@ public class FarmShell {
getAnalyzor().newsSpread(params[0]);
break;
case getBrands:
- String trimmed = params[0].trim();
- String bool = trimmed;
- String query = null;
-
- int index = trimmed.indexOf(" ");
-
- if (index > -1) {
- bool = trimmed.substring(0, index);
- query = trimmed.substring(index + 1, trimmed.length());
- }
+ String query = params.length > 0 ? params[0].trim() : "";
+ String[] args = query.split("\\s+", 2);
+ // by default, do not reset the database.
boolean reset = false;
- if (bool.equals("true")) {
- reset = true;
- } else if (bool.equals("false")) {
- reset = false;
- } else {
- throw new IllegalArgumentException("getBrands: expected boolean, got " + params[0]);
+ if (args.length == 2) {
+ if (args[0].equals("RESET")) {
+ reset = true;
+ query = args[1].trim();
+ }
}
- if (query != null) {
- getAnalyzor().getBrands(query, reset);
- } else {
- getAnalyzor().getBrands("", reset);
- }
+ getAnalyzor().getBrands(query, reset);
break;
case help:
for (String line : HELP) {
@@ -202,7 +190,7 @@ public class FarmShell {
filterbots("marks all users as bot or not", 1),
sentiment("analyzes all tweets on brand positivity (optional arg: tweet/brand selection query)"),
wordcloud("makes a csv for a wordcloud of the text of the tweets", 1),
- getBrands("fills the database with the brands of a tweet, arg: bool indicating whether to reset mentionsbrand (optional arg: tweet selection query", 1),
+ getBrands("fills the database with the brands of a tweet. optional args: RESET to truncate mentionsbrand; tweet selection query"),
timezone("makes a map per brand for the users", 1),
disco("makes a outputfile for disco", 1),
posneg("makes a csv for a histogram for positive or negative tweets", 1),