From 88bb3ee2dfa6948101dec0589a15ec368be36506 Mon Sep 17 00:00:00 2001 From: Crista Lopes Date: Tue, 13 Aug 2019 09:17:37 -0700 Subject: [PATCH] Better --- 03-arrays/tf-03.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/03-arrays/tf-03.py b/03-arrays/tf-03.py index e220035..96903bc 100644 --- a/03-arrays/tf-03.py +++ b/03-arrays/tf-03.py @@ -12,27 +12,27 @@ characters = np.char.lower(characters) # Result: array([' ', 'h', 'e', 'l', 'l', 'o', ' ', ' ', # 'w', 'o', 'r', 'l', 'd', ' ', ' '], dtype=' 1)] +# Result: array([[ 0, 6], +# [ 7, 13]], dtype=int64) # Voila! Words are in between spaces, given as pairs of indices -# But skip contiguous spaces (the conditional at the end) -words = [characters[w_ranges[i][0] : w_ranges[i][1]] for i in range(len(w_ranges)) if w_ranges[i][1]-w_ranges[i][0] > 1] +words = [characters[w_ranges[i][0] : w_ranges[i][1]] for i in range(len(w_ranges))] # Result: [array([' ', 'h', 'e', 'l', 'l', 'o'], dtype='