uk.ac.cam.juliet.twitter.analysis
Class FrequencyCounter

java.lang.Object
  extended by uk.ac.cam.juliet.twitter.analysis.FrequencyCounter

public class FrequencyCounter
extends java.lang.Object


Field Summary
(package private)  IDatabase db
          the database that is used to load the stopwords
(package private)  ProfanityFilter filter
          swear filter
 java.util.HashSet<java.lang.String> stopwords
          the stopwords that are loaded from the dictionary
 
Constructor Summary
FrequencyCounter(IDatabase db)
          constructor
 
Method Summary
 java.util.Dictionary<java.lang.String,java.lang.Integer> getCounts(java.lang.String sentence)
          creates a dictionary that contains every word in the sentence as key, and the number of occurrences of that word in the sentence as the corresponding value to the key
static void main(java.lang.String[] args)
           
 java.util.List<java.lang.String> removeNumbers(java.util.List<java.lang.String> words)
          removes any element in the list words that is a number, either an integer like 44 or a real number like 3.14 or -2.1e4
 java.util.List<java.lang.String> removeStopWords(java.util.List<java.lang.String> words)
          removes any stop words from the input strings
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

db

IDatabase db
the database that is used to load the stopwords


filter

ProfanityFilter filter
swear filter


stopwords

public java.util.HashSet<java.lang.String> stopwords
the stopwords that are loaded from the dictionary

Constructor Detail

FrequencyCounter

public FrequencyCounter(IDatabase db)
constructor

Parameters:
db - the database from which to get the stopwords
Method Detail

getCounts

public java.util.Dictionary<java.lang.String,java.lang.Integer> getCounts(java.lang.String sentence)
creates a dictionary that contains every word in the sentence as key, and the number of occurrences of that word in the sentence as the corresponding value to the key

Parameters:
sentence - count the words in this sentence
Returns:
a dictionary that contains every word in the sentence as key, and the number of occurrences of that word in the sentence as the corresponding value to the key

removeStopWords

public java.util.List<java.lang.String> removeStopWords(java.util.List<java.lang.String> words)
removes any stop words from the input strings

Parameters:
words - the list from which the function should remove stopwords
Returns:
the same input list but with all stop words removed

removeNumbers

public java.util.List<java.lang.String> removeNumbers(java.util.List<java.lang.String> words)
removes any element in the list words that is a number, either an integer like 44 or a real number like 3.14 or -2.1e4

Parameters:
words - a list of strings that need to be filtered
Returns:
the same list with all number strings removed

main

public static void main(java.lang.String[] args)
                 throws java.sql.SQLException,
                        java.lang.ClassNotFoundException
Throws:
java.sql.SQLException
java.lang.ClassNotFoundException