def poll_collect(db, seconds): while True: collect_comments(db, fetch_latest_comments()) for remaining in range(seconds, 0, -1): set_line('Requesting comments again in %s seconds...' % remaining) time.sleep(1) set_line('')
def build_chain(db, max_comments=None): c = Chain(tokenizer=markdown_tokenizer(), N=10) comment_count = len(db) if max_comments: comment_count = min(comment_count, max_comments) for index, comment_id in enumerate(db): body = db[comment_id]['body'] c.train(body) set_line('Loaded %s/%s comments...' % (index+1, comment_count)) if max_comments and index+1 >= max_comments: break set_line('') return c
def build_chain(db, max_comments=None): c = Chain(tokenizer=markdown_tokenizer(), N=10) comment_count = len(db) if max_comments: comment_count = min(comment_count, max_comments) for index, comment_id in enumerate(db): body = db[comment_id]['body'] c.train(body) set_line('Loaded %s/%s comments...' % (index + 1, comment_count)) if max_comments and index + 1 >= max_comments: break set_line('') return c