|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.tootsville.hangman.Censor
public class Censor
Provides chat filtering.
| Field Summary | |
|---|---|
(package private) static CopyOnWriteArraySet<String> |
adjacentList
WRITEME: document this field (brpocock@star-hope.org, Nov 5, 2009) adjacentList (Censor) |
(package private) static CopyOnWriteArraySet<String> |
blackList
WRITEME: document this field (brpocock@star-hope.org, Nov 5, 2009) blackList (Censor) |
(package private) static Pattern |
numberPattern
Removing digits |
(package private) static CopyOnWriteArraySet<String> |
oneList
WRITEME: document this field (brpocock@star-hope.org, Nov 5, 2009) oneList (Censor) |
(package private) static Pattern |
sgmlEntityPattern
Pattern to remove SGML-type entities |
(package private) static Pattern |
shoutingPattern
No shouting |
(package private) static Pattern |
symbolsPattern
Symbols to be removed before filtering a sentence |
(package private) static ConcurrentHashMap<String,Integer> |
weights
WRITEME: document this field (brpocock@star-hope.org, Nov 5, 2009) weights (Censor) |
(package private) static CopyOnWriteArraySet<String> |
whiteList
WRITEME: document this field (brpocock@star-hope.org, Nov 5, 2009) whiteList (Censor) |
(package private) static CopyOnWriteArraySet<String> |
worseList
WRITEME: document this field (brpocock@star-hope.org, Nov 5, 2009) worseList (Censor) |
| Constructor Summary | |
|---|---|
Censor()
|
|
| Method Summary | |
|---|---|
static void |
addToAdjacentList(String word)
Add a word to the adjacent word list. |
static void |
addToBlackList(String word)
Add a word to the Black list. |
static void |
addToWhiteList(String word)
Add a word to the White list. |
static void |
addToWorseList(String word)
Add a word to the Worse (Red) list. |
private static FilterResult |
checkAdjacentLists(String token)
Check if a token matches a full word in any of the filtering lists. |
private static FilterResult |
checkAdjacentTokens(List<String> tokens)
WRITEME: document this method |
FilterResult |
checkLists(String token)
WRITEME: document this method (brpocock@star-hope.org, Oct 13, 2009) |
private FilterResult |
checkTokens(List<String> tokens)
WRITEME: document this method |
void |
destroy()
Release the hash tables. |
FilterResult |
filterMessage(String text)
Filter the message. |
static int |
getBlackListLength()
WRITEME: document this method (brpocock@star-hope.org, Oct 13, 2009) |
int |
getWhiteListLength()
WRITEME: document this method (brpocock@star-hope.org, Oct 13, 2009) |
static int |
getWorseListLength()
WRITEME: document this method (brpocock@star-hope.org, Oct 13, 2009) |
static void |
init()
Initialize the filtering word sets. |
private static boolean |
inWhitelist(String word,
CopyOnWriteArraySet<String> copyOnWriteArraySet)
Determine if the word is a white listed word. |
void |
loadLists(Connection dbh)
WRITEME: document this method (brpocock@star-hope.org, Oct 13, 2009) |
void |
prime(Connection databaseConnection)
WRITEME: Document this method brpocock@star-hope.org |
void |
reloadLists(Connection dbh)
Clear all censors and reload them. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
static volatile CopyOnWriteArraySet<String> adjacentList
static volatile CopyOnWriteArraySet<String> blackList
static final Pattern numberPattern
static volatile CopyOnWriteArraySet<String> oneList
static final Pattern sgmlEntityPattern
static final Pattern shoutingPattern
static final Pattern symbolsPattern
static volatile ConcurrentHashMap<String,Integer> weights
static volatile CopyOnWriteArraySet<String> whiteList
static volatile CopyOnWriteArraySet<String> worseList
| Constructor Detail |
|---|
public Censor()
| Method Detail |
|---|
public static void addToAdjacentList(String word)
word - WRITEMEpublic static void addToBlackList(String word)
word - WRITEMEpublic static void addToWhiteList(String word)
word - WRITEMEpublic static void addToWorseList(String word)
word - WRITEMEprivate static FilterResult checkAdjacentLists(String token)
token - to be checked.
private static FilterResult checkAdjacentTokens(List<String> tokens)
tokens - WRITEME
public static int getBlackListLength()
public static int getWorseListLength()
public static void init()
private static boolean inWhitelist(String word,
CopyOnWriteArraySet<String> copyOnWriteArraySet)
word - Word to check.copyOnWriteArraySet - List to check.
public FilterResult checkLists(String token)
AbstractCensor
checkLists in interface AbstractCensortoken - WRITEME
AbstractCensor.checkLists(java.lang.String)private FilterResult checkTokens(List<String> tokens)
tokens - WRITEME
public void destroy()
public FilterResult filterMessage(String text)
AbstractCensor
filterMessage in interface AbstractCensortext - WRITEME
AbstractCensor.filterMessage(java.lang.String)public int getWhiteListLength()
AbstractCensor
getWhiteListLength in interface AbstractCensorAbstractCensor.getWhiteListLength()public void loadLists(Connection dbh)
loadLists in interface AbstractCensordbh - A live database connection from which to load the
censorship listspublic void prime(Connection databaseConnection)
AbstractCensor
prime in interface AbstractCensordatabaseConnection - An open database connection over which
the censorship records can be loadedpublic void reloadLists(Connection dbh)
reloadLists in interface AbstractCensordbh - A live database connection from which to load the
censorship lists
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||