From 8a7d2e7fbd2b9b5a2a365431f000c5c1a3d6efe5 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 11 Jun 2014 11:11:00 +0200 Subject: Change to use 'RESET' instead of boolean Also make selection query smaller --- src/main/Analyzor.java | 2 +- src/main/FarmShell.java | 32 ++++++++++---------------------- 2 files changed, 11 insertions(+), 23 deletions(-) (limited to 'src') 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), -- cgit v1.2.1