Massive renaming!
This commit is contained in:
2
20-plugins/plugins-src/compile.sh
Normal file
2
20-plugins/plugins-src/compile.sh
Normal file
@@ -0,0 +1,2 @@
|
||||
python -m compileall .
|
||||
cp *.pyc ../plugins
|
||||
11
20-plugins/plugins-src/frequencies1.py
Normal file
11
20-plugins/plugins-src/frequencies1.py
Normal 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]
|
||||
|
||||
6
20-plugins/plugins-src/frequencies2.py
Normal file
6
20-plugins/plugins-src/frequencies2.py
Normal 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)
|
||||
|
||||
14
20-plugins/plugins-src/words1.py
Normal file
14
20-plugins/plugins-src/words1.py
Normal 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]
|
||||
|
||||
7
20-plugins/plugins-src/words2.py
Normal file
7
20-plugins/plugins-src/words2.py
Normal 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]
|
||||
|
||||
Reference in New Issue
Block a user