Some changes and new stuff

This commit is contained in:
RussellChamp committed 2015-08-24 10:04:57 -05:00
1 parent 33ea98b002
commit 0b5a4fcfb8
19 files changed
+900 -9

No files matched your search

+199
View File
@@ -0,0 +1,199 @@
aboard
about
above
across
after
against
along
amid
among
anti
around
as
at
before
behind
below
beneath
beside
besides
between
beyond
but
by
concerning
considering
despite
down
during
except
excepting
excluding
following
for
from
in
inside
into
like
minus
near
of
off
on
onto
opposite
outside
over
past
per
plus
regarding
round
save
since
than
through
to
toward
towards
under
underneath
unlike
until
up
upon
versus
via
with
within
without
all
another
any
anybody
anyone
anything
both
each
either
everybody
everyone
everything
few
he
her
hers
herself
him
himself
his
it
its
itself
many
me mine
more
most
much
my
myself
neither
no one
nobody
none
one
other
others
our
ours
ourselves
several
she
some
somebody
someone
something
that
their
theirs
them
themselves
these
they
this
those
us
we
what
whatever
which
whichever
who
whoever
whom
whomever
whose
you
your
yours
yourself
yourselves
an
am
as
to
up
us
in
be
can
how
get
got
has
did
every
also
too
try
is
was
do
if
oh
so
ill
are
been
or
dont
just
had
set
put
have
im
ive
not
then
goes
youre
use
id
the
a
and
i
me
when
where
how
would
whats
because
thats
there
doing
even
does
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/python
import fileinput
import json
import time
import calendar
import shutil
logfile = "/home/jumblesale/Code/irc/log"
outfile = "/home/krowbar/logs/userData.json"
userData = {} #hash keyed by "user" that contains an array of timestamps
#we only care about recent chats, let's say for the past two weeks
timeCutoff = calendar.timegm(time.gmtime()) - (2 * 7 * 24 * 60 * 60)
with open(logfile, "r") as log:
for line in log:
try:
time, user, message = line.split("\t", 3)
time = int(time)
except ValueError:
continue #There are some bad lines in the log file that we'll ignore if we can't parse
if time > timeCutoff:
#if the user already exists in the list
if user in userData:
userData[user].append(time) #append the new time
else: #if they are new
userData[user] = [time] #create a new list
with open(outfile + ".tmp", "w") as tmpFile:
tmpFile.write(json.dumps(userData))
shutil.move(outfile + ".tmp", outfile)
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/python
import fileinput
import json
import time
import calendar
import re
import shutil
logfile = "/home/jumblesale/Code/irc/log"
outfile = "/home/krowbar/logs/chatcloud.json"
bannedWordsFile = "/home/krowbar/Code/python/bannedWords"
wordData = {} # keyed by "word" that contains a count
#we only care about recent chats, let's say for the past two weeks
timeCutoff = calendar.timegm(time.gmtime()) - (2 * 7 * 24 * 60 * 60)
minOccurance = 10
bannedWords = open(bannedWordsFile).read().splitlines()
with open(logfile, "r") as log:
for line in log:
try:
time, user, message = line.split("\t", 3)
time = int(time)
except ValueError:
continue #There are some bad lines in the log file that we'll ignore if we can't parse
if time > timeCutoff:
for word in re.sub('[\'\";:,.?!*&^\-()\[\]]', '', message).lower().split():
if word in bannedWords:
continue
#if the word already exists in the list
if word in wordData:
wordData[word] += 1
else: #if they are new
wordData[word] = 1
#print "Added word: " + word
wordData = {i:wordData[i] for i in wordData if wordData[i] >= minOccurance }
with open(outfile + ".tmp", "w") as tmpFile:
tmpFile.write(json.dumps(wordData))
shutil.move(outfile + ".tmp", outfile)