From e0b8557e10493b6e54209a6cdf463e39634cfbfd Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Thu, 6 Mar 2014 11:17:50 -0500 Subject: [PATCH] Moved ngrams --- cipher.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/cipher.py b/cipher.py index 59eb3a6..c5d542b 100644 --- a/cipher.py +++ b/cipher.py @@ -19,18 +19,6 @@ for a in range(26): modular_division_table[b][c] = a -def ngrams(text, n): - """Returns all n-grams of a text - - >>> ngrams(sanitise('the quick brown fox'), 2) # doctest: +NORMALIZE_WHITESPACE - ['th', 'he', 'eq', 'qu', 'ui', 'ic', 'ck', 'kb', 'br', 'ro', 'ow', 'wn', - 'nf', 'fo', 'ox'] - >>> ngrams(sanitise('the quick brown fox'), 4) # doctest: +NORMALIZE_WHITESPACE - ['theq', 'hequ', 'equi', 'quic', 'uick', 'ickb', 'ckbr', 'kbro', 'brow', - 'rown', 'ownf', 'wnfo', 'nfox'] - """ - return [text[i:i+n] for i in range(len(text)-n+1)] - def every_nth(text, n, fillvalue=''): """Returns n strings, each of which consists of every nth character, starting with the 0th, 1st, 2nd, ... (n-1)th character -- 2.34.1