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.java38
1 files changed, 26 insertions, 12 deletions
diff --git a/src/main/Analyzor.java b/src/main/Analyzor.java
index b7e1dc0..e7e26fe 100644
--- a/src/main/Analyzor.java
+++ b/src/main/Analyzor.java
@@ -12,16 +12,22 @@ import java.util.HashMap;
import java.util.Scanner;
/**
- * Analyze tweets with a lexicon.
+ * The sentiment analysis class that rates tweets based on a unigram and bigram
+ * set of weights.
*/
public class Analyzor {
- //maps for the lexicons
- HashMap<String, Double> unimap = new HashMap<>(); // Map for uni
- HashMap<String, Double> bimap = new HashMap<>(); // Map for bi
+ /**
+ * The map that matches single words to their weights.
+ */
+ private final HashMap<String, Double> unimap = new HashMap();
- //the resultset of the query or the import
- ResultSet data;
+ /**
+ * The map that matches word pairs to their weights.
+ */
+ private final HashMap<String, Double> bimap = new HashMap();
+
+ private ResultSet data;
private final Connection connection;
Analyzor(Connection connection) {
@@ -59,18 +65,26 @@ public class Analyzor {
}
}
- //query the database
- //fills the ResultSet data
- void query(String query) throws SQLException {
+ /**
+ * Executes a query that the analyzer can analyze.
+ *
+ * @param query The query string to execute.
+ * @throws SQLException When database connection isn't available.
+ */
+ public void query(String query) throws SQLException {
PreparedStatement statement;
//make a connection to the database and execute the query
statement = connection.prepareStatement(query);
data = statement.executeQuery();
}
- //analyzes the tweet on their positivity
- //this is just a base version
- void sentimentAnalysis(String query) throws SQLException, IOException {
+ /**
+ * Run a sentiment analysis and fill the database with the output.
+ *
+ * @throws SQLException
+ * @throws IOException
+ */
+ public void sentimentAnalysis(String query) throws SQLException, IOException {
query(query);
//read the lexicons