From 8da7d10ea75044933cf72c46fb8e27d59aeda563 Mon Sep 17 00:00:00 2001 From: Maurice Laveaux Date: Mon, 19 May 2014 11:45:50 +0200 Subject: Added javadoc and visibility parameters. --- src/main/Analyzor.java | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/main/Analyzor.java b/src/main/Analyzor.java index 42d3c4e..678887f 100644 --- a/src/main/Analyzor.java +++ b/src/main/Analyzor.java @@ -13,7 +13,6 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; -import java.util.Map.Entry; import java.util.Scanner; /** @@ -32,15 +31,29 @@ public class Analyzor { */ private final HashMap bimap = new HashMap(); + /** + * The results of a query, maybe return from query(). + */ private ResultSet data; + + /** + * The persistent connection to the database. + */ private final Connection connection; - Analyzor(Connection connection) { + /** + * @param connection An open connection to the database. + */ + public Analyzor(Connection connection) { this.connection = connection; } - //reads the lexicons - void readLexicon() throws FileNotFoundException { + /** + * Read the unigram and bigram lexica. + * + * @throws FileNotFoundException + */ + public void readLexicon() throws FileNotFoundException { if (!unimap.isEmpty()) { // data is already read. return; @@ -88,6 +101,7 @@ public class Analyzor { /** * Run a sentiment analysis and fill the database with the output. * + * @param query The sql text for the query. * @throws SQLException * @throws IOException */ @@ -140,8 +154,15 @@ public class Analyzor { } } - //makes a wordcloud of the tweets in the ResultSet data - void makeWordCloud(String query) throws SQLException, FileNotFoundException, UnsupportedEncodingException { + /** + * Make a wordcloud of the results of some query. + * + * @param query The sql text for a query. + * @throws SQLException + * @throws FileNotFoundException + * @throws UnsupportedEncodingException + */ + public void makeWordCloud(String query) throws SQLException, FileNotFoundException, UnsupportedEncodingException { query(query); //go to the start of the ResultSet data @@ -239,8 +260,8 @@ public class Analyzor { //also removes urls private String removePunct(String text) { text = text.replaceAll("https?://\\S*", ""); - text = text.replaceAll("[.,!?()-:;\"']", " "); - text = text.replaceAll("[^\\x00-\\x7F]", ""); + text = text.replaceAll("[.,!?();\"'-]", " "); + text = text.replaceAll("[^\\x00-\\x7F]", " "); return text; } } -- cgit v1.2.1