General
Heat detector is a stackapp running as bot, that query comments api for all comments on Stackoverflow to catch offensive, rude, snarky comments and comments that leads to abusive content (offensive, spam posts or previous offensive comments)
The comments are output in chat for manual review.
Example
To avoid storing comments in chat transcript (unearth buried fights), the comment is automatically deleted from chat before timeout.
The bot also have both a test function and a report function, that enables possibility to test different comments and to train the classifiers on uncaught content.
Implementation
The comments api is queried every 1,5 min-3 min depending on traffic, the objective of query interval is to get all last comments within 1 page result (max 100 comments), to reduce api calls to a minimum.
All comments are processed both by regex and machine learning algorithms (NLP), they all contributes to a final score. If score is above set threshold the comment is outputted to chat.
Pre-processing
Before regex is applied the comment is pre-processed removing username, html tags and ripetitive characters. Before NLP classification also code blocks, links and non normal ASCII chars are removed.
Regular expressions
The regex system is divided in three external text files; high, medium and low scoring regex.
Natural language processing (NLP)
Currently 2 different NLP systems are used. On the basis of the predicated value the score is increased.
NLP Feed
The classifier has a feed divided in 2 categories, the good feed that is a download of old (>90 days) comments from comment api and a bad feed that is a composition of:
Feed provided by SE, these comments have been reviewed manually and almost 50% removed as they did not seem to be within scope
Comments captured incorrectly or correctly during testing
Twitter feed provided by Laurel
Currently the feed contains 2000 good SO comments and 2000 (1000 SO, 1000 Twitter) bad comments .
NaiveBayesMultinomialText
The classifier runs with these primary settings:
useWordFrequency: false (comments are to short to use word frequency)
lowercaseTokens: true
NormalizeDocLenght: false
Stemmer: IteratedLovinsStemmer
Stopwords: Standard english stopwords
Tokenizer: NGramTokenizer (min 1, max 3)
The settings have been chosen on basis of cross validation and classification result on training set. Testing on training set it has correctly classified instances at 99.075%
Apache OpenNLP
Apache Open NLP standard DocumentCategorizerME
, is used with these non default settings:
FeatureGenerator: BagOfWordsFeatureGenerator
WhitespaceTokenizer: WhitespaceTokenizer.INSTANCE
CUTOFF_PARAM: 0
ITERATIONS_PARAM: 4000
Testing on training set it has correctly classified instances at 99.823%, with 7 comments out of 4000 not classified correctly
Other classifiers
Other classifiers as J48, SMO and SGDText have been test but without good results.
Accounts
The bot run under same user as SOCVFinder the Queen. The main reason is to leverage calls to comments api from same server, hence SOCVFinder already query comments api for possibile duplicates.
Source code
Source code is available on GitHub.
Status
This stackapp is currently in testing phase, to understand correct regex and specially to improve feed, including new bad SO comments replacing the twitter feed comments. The objective is to run on 3000 good/bad only SO comments.