Minor cleanups
This commit is contained in:
@@ -93,7 +93,6 @@ def sort():
|
|||||||
# Not in style, left as exercise
|
# Not in style, left as exercise
|
||||||
stack.extend(sorted(stack.pop().iteritems(), key=operator.itemgetter(1)))
|
stack.extend(sorted(stack.pop().iteritems(), key=operator.itemgetter(1)))
|
||||||
|
|
||||||
#
|
|
||||||
# The main function
|
# The main function
|
||||||
#
|
#
|
||||||
stack.append(sys.argv[1])
|
stack.append(sys.argv[1])
|
||||||
|
|||||||
@@ -15,9 +15,8 @@ def read_file(path_to_file):
|
|||||||
contents of the file to the global variable data
|
contents of the file to the global variable data
|
||||||
"""
|
"""
|
||||||
global data
|
global data
|
||||||
f = open(path_to_file)
|
with open(path_to_file) as f:
|
||||||
data = data + list(f.read())
|
data = data + list(f.read())
|
||||||
f.close()
|
|
||||||
|
|
||||||
def filter_chars_and_normalize():
|
def filter_chars_and_normalize():
|
||||||
"""
|
"""
|
||||||
@@ -41,9 +40,8 @@ def scan():
|
|||||||
|
|
||||||
def remove_stop_words():
|
def remove_stop_words():
|
||||||
global words
|
global words
|
||||||
f = open('../stop_words.txt')
|
with open('../stop_words.txt') as f:
|
||||||
stop_words = f.read().split(',')
|
stop_words = f.read().split(',')
|
||||||
f.close()
|
|
||||||
# add single-letter words
|
# add single-letter words
|
||||||
stop_words.extend(list(string.ascii_lowercase))
|
stop_words.extend(list(string.ascii_lowercase))
|
||||||
indexes = []
|
indexes = []
|
||||||
|
|||||||
Reference in New Issue
Block a user