Annotate bots/summarize_stream.py.

This commit is contained in:
Tim Abbott 2016-09-10 12:23:44 -07:00
parent 98ac51d07d
commit 54820de522
1 changed files with 6 additions and 2 deletions

View File

@ -7,8 +7,9 @@ import zulip
import re import re
import collections import collections
def get_recent_messages(client, narrow, count=100): def get_recent_messages(client, narrow_str, count=100):
narrow = [word.split(':') for word in narrow.split()] # type: (zulip.Client, str, int) -> List[Dict[str, Any]]
narrow = [word.split(':') for word in narrow_str.split()]
req = { req = {
'narrow': narrow, 'narrow': narrow,
'num_before': count, 'num_before': count,
@ -22,6 +23,7 @@ def get_recent_messages(client, narrow, count=100):
return old_messages['messages'] return old_messages['messages']
def get_words(content): def get_words(content):
# type: (str) -> List[str]
regex = "[A-Z]{2,}(?![a-z])|[A-Z][a-z]+(?=[A-Z])|[\'\w\-]+" regex = "[A-Z]{2,}(?![a-z])|[A-Z][a-z]+(?=[A-Z])|[\'\w\-]+"
words = re.findall(regex, content, re.M) words = re.findall(regex, content, re.M)
words = [w.lower() for w in words] words = [w.lower() for w in words]
@ -29,6 +31,7 @@ def get_words(content):
return words return words
def analyze_messages(msgs, word_count, email_count): def analyze_messages(msgs, word_count, email_count):
# type: (List[Dict[str, Any]], Dict[str, int], Dict[str, int]) -> None
for msg in msgs: for msg in msgs:
if False: if False:
if ' ack' in msg['content']: if ' ack' in msg['content']:
@ -47,6 +50,7 @@ def analyze_messages(msgs, word_count, email_count):
print('%-20s: %s' % (k, v)) print('%-20s: %s' % (k, v))
def generate_support_stats(): def generate_support_stats():
# type: () -> None
client = zulip.Client() client = zulip.Client()
narrow = 'stream:support' narrow = 'stream:support'
count = 2000 count = 2000