Finally rewrote the code for Python3!
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
import sys, re, operator, string, os
|
||||
|
||||
#
|
||||
@@ -22,7 +21,7 @@ def frequencies_imp(word_list):
|
||||
if len(sys.argv) > 1:
|
||||
extract_words_func = "lambda name : [x.lower() for x in re.split('[^a-zA-Z]+', open(name).read()) if len(x) > 0 and x.lower() not in stops]"
|
||||
frequencies_func = "lambda wl : frequencies_imp(wl)"
|
||||
sort_func = "lambda word_freq: sorted(word_freq.iteritems(), key=operator.itemgetter(1), reverse=True)"
|
||||
sort_func = "lambda word_freq: sorted(word_freq.items(), key=operator.itemgetter(1), reverse=True)"
|
||||
filename = sys.argv[1]
|
||||
else:
|
||||
extract_words_func = "lambda x: []"
|
||||
|
||||
Reference in New Issue
Block a user