From 053bec0fc1962a15d69c54bb563e6a728cd7189f Mon Sep 17 00:00:00 2001 From: Crista Lopes Date: Mon, 12 Aug 2019 14:15:10 -0700 Subject: [PATCH] Clean up APL code and sprinkle an example in comments --- zothers/apl.py | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/zothers/apl.py b/zothers/apl.py index cfe14ab..e20705f 100644 --- a/zothers/apl.py +++ b/zothers/apl.py @@ -1,31 +1,47 @@ import sys, string import numpy as np -from itertools import count # Get an array of characters from the file, make sure it starts and ends with a space +# Example input: "Hello World! " characters = np.array([' '] + list(open(sys.argv[1]).read()) + [' ']) -# Stop words -stop_words = open('../stop_words.txt').read().split(',') -stop_words.extend(list(string.ascii_lowercase)) -stop_words = np.array(list(set(stop_words))) +# Result: array([' ', 'H', 'e', 'l', 'l', 'o', ' ', ' ', +# 'W', 'o', 'r', 'l', 'd', '!', ' ', ' '], dtype=' 1] +# Result: [array([' ', 'h', 'e', 'l', 'l', 'o'], dtype='