#!/usr/bin/python -S
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()