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