def scan_post(post): # check if there are any symbols in the post syms = [] for s in TRACKED_SYMBOLS: if scan_post_for_symbol(post,s): syms.append(s['ticker']) # if any symbols present, save t if syms: post['syms'] = syms # scan for any profanity if profanity.is_profane(post['fulltext']) or profanity.is_profane(post['title']): post['profanity'] = True # scan for sentiment # prioritise fulltext sen = 0.5 # inside try as if it goes wrong want to just mark it neutral as posts are limited try: if len(post['fulltext']): sen = sentiment.classify(post['fulltext']) elif len(post['title']): sen = sentiment.classify(post['title']) else: # if all are null this is pointless anyway return except: traceback.print_exc() L.error("Failed to get sentiment") L.info("Found sentiment: {}".format(sen)) post['sentiment'] = sen OUTBOUND_QUEUE.put(post)
def check(word): assert_true(is_profane(word), word)
def check(word): assert_false(is_profane(word), word)