Report abuse
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import re
import sys
from os import environ as env
sys.path.insert(0, env["TM_SUPPORT_PATH"] + "/lib")
import webpreview
content = sys.stdin.read()
swear_words = [r"f[oO0]+ck(er|ing)", r"\bbar\b", r"\bbaz\b"]
swear_counts = {}
for exp in swear_words:
matches = re.findall(exp, content, re.M)
print matches
swear_counts[word] = len(matches)
print webpreview.html_header("SwearCount", "")
print "<table>"
for word in swear_counts.keys():
print "<tr><td>%s</td><td>%i</td></tr>" % (word, swear_counts[word])
print "</table>"
print webpreview.html_footer()
|