Massive renaming!

This commit is contained in:
Crista Lopes
2019-08-12 14:38:16 -07:00
parent e6c1238a56
commit 61d5f74ad9
90 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
python -m compileall .
cp *.pyc ../plugins

View File

@@ -0,0 +1,11 @@
import operator
def top25(word_list):
word_freqs = {}
for w in word_list:
if w in word_freqs:
word_freqs[w] += 1
else:
word_freqs[w] = 1
return sorted(word_freqs.items(), key=operator.itemgetter(1), reverse=True)[:25]

View File

@@ -0,0 +1,6 @@
import operator, collections
def top25(word_list):
counts = collections.Counter(w for w in word_list)
return counts.most_common(25)

View File

@@ -0,0 +1,14 @@
import sys, re, string
def extract_words(path_to_file):
with open(path_to_file) as f:
str_data = f.read()
pattern = re.compile('[\W_]+')
word_list = pattern.sub(' ', str_data).lower().split()
with open('../stop_words.txt') as f:
stop_words = f.read().split(',')
stop_words.extend(list(string.ascii_lowercase))
return [w for w in word_list if not w in stop_words]

View File

@@ -0,0 +1,7 @@
import sys, re, string
def extract_words(path_to_file):
words = re.findall('[a-z]{2,}', open(path_to_file).read().lower())
stopwords = set(open('../stop_words.txt').read().split(','))
return [w for w in words if w not in stopwords]