Add -w switch to getmentions allowing to get stats for all words (whitespace-delimited strings) ever tweeted

This commit is contained in:
Klaus-Uwe Mitterer 2015-04-25 01:25:33 +02:00
parent def6fca403
commit 0cacd2d0c7

View file

@ -13,8 +13,11 @@ def getTweets(mode = "@", path = tools.config.dbpath):
for tweet in tweets:
for word in tweet[0].split():
if word[0] == mode:
handle = mode + re.split('[\\W]',word[1:])[0].lower()
if word[0] == mode or mode == "":
if mode == "":
handle = word
else:
handle = mode + re.split('[\\W]',word[1:])[0].lower()
if handle != mode:
try:
handles[handle] += 1
@ -34,6 +37,8 @@ if __name__ == "__main__":
for arg in sys.argv[1:]:
if arg == "-h":
mode = "#"
if arg == "-w":
mode = ""
else:
path = arg