diff --git a/17-introspective/README.md b/15-introspective/README.md similarity index 100% rename from 17-introspective/README.md rename to 15-introspective/README.md diff --git a/17-introspective/tf-17.py b/15-introspective/tf-15.py similarity index 100% rename from 17-introspective/tf-17.py rename to 15-introspective/tf-15.py diff --git a/18-reflective/README.md b/16-reflective/README.md similarity index 100% rename from 18-reflective/README.md rename to 16-reflective/README.md diff --git a/18-reflective/tf-18.py b/16-reflective/tf-16.py similarity index 100% rename from 18-reflective/tf-18.py rename to 16-reflective/tf-16.py diff --git a/19-asides/README.md b/17-asides/README.md similarity index 100% rename from 19-asides/README.md rename to 17-asides/README.md diff --git a/19-asides/tf-19.py b/17-asides/tf-17.py similarity index 100% rename from 19-asides/tf-19.py rename to 17-asides/tf-17.py diff --git a/20-no-commitment/README.md b/18-no-commitment/README.md similarity index 100% rename from 20-no-commitment/README.md rename to 18-no-commitment/README.md diff --git a/20-no-commitment/config.ini b/18-no-commitment/config.ini similarity index 100% rename from 20-no-commitment/config.ini rename to 18-no-commitment/config.ini diff --git a/20-no-commitment/plugins-src/compile.sh b/18-no-commitment/plugins-src/compile.sh similarity index 100% rename from 20-no-commitment/plugins-src/compile.sh rename to 18-no-commitment/plugins-src/compile.sh diff --git a/20-no-commitment/plugins-src/frequencies1.py b/18-no-commitment/plugins-src/frequencies1.py similarity index 100% rename from 20-no-commitment/plugins-src/frequencies1.py rename to 18-no-commitment/plugins-src/frequencies1.py diff --git a/20-no-commitment/plugins-src/frequencies2.py b/18-no-commitment/plugins-src/frequencies2.py similarity index 100% rename from 20-no-commitment/plugins-src/frequencies2.py rename to 18-no-commitment/plugins-src/frequencies2.py diff --git a/20-no-commitment/plugins-src/words1.py b/18-no-commitment/plugins-src/words1.py similarity index 100% rename from 20-no-commitment/plugins-src/words1.py rename to 18-no-commitment/plugins-src/words1.py diff --git a/20-no-commitment/plugins-src/words2.py b/18-no-commitment/plugins-src/words2.py similarity index 100% rename from 20-no-commitment/plugins-src/words2.py rename to 18-no-commitment/plugins-src/words2.py diff --git a/20-no-commitment/plugins/frequencies1.pyc b/18-no-commitment/plugins/frequencies1.pyc similarity index 100% rename from 20-no-commitment/plugins/frequencies1.pyc rename to 18-no-commitment/plugins/frequencies1.pyc diff --git a/20-no-commitment/plugins/frequencies2.pyc b/18-no-commitment/plugins/frequencies2.pyc similarity index 100% rename from 20-no-commitment/plugins/frequencies2.pyc rename to 18-no-commitment/plugins/frequencies2.pyc diff --git a/20-no-commitment/plugins/words1.pyc b/18-no-commitment/plugins/words1.pyc similarity index 100% rename from 20-no-commitment/plugins/words1.pyc rename to 18-no-commitment/plugins/words1.pyc diff --git a/20-no-commitment/plugins/words2.pyc b/18-no-commitment/plugins/words2.pyc similarity index 100% rename from 20-no-commitment/plugins/words2.pyc rename to 18-no-commitment/plugins/words2.pyc diff --git a/20-no-commitment/tf-20.py b/18-no-commitment/tf-18.py similarity index 100% rename from 20-no-commitment/tf-20.py rename to 18-no-commitment/tf-18.py diff --git a/21-constructivist/README.md b/19-constructivist/README.md similarity index 100% rename from 21-constructivist/README.md rename to 19-constructivist/README.md diff --git a/21-constructivist/tf-21.py b/19-constructivist/tf-19.py similarity index 100% rename from 21-constructivist/tf-21.py rename to 19-constructivist/tf-19.py diff --git a/22-tantrum/README.md b/20-tantrum/README.md similarity index 100% rename from 22-tantrum/README.md rename to 20-tantrum/README.md diff --git a/22-tantrum/tf-22.py b/20-tantrum/tf-20.py similarity index 100% rename from 22-tantrum/tf-22.py rename to 20-tantrum/tf-20.py diff --git a/23-passive-aggressive/README.md b/21-passive-aggressive/README.md similarity index 100% rename from 23-passive-aggressive/README.md rename to 21-passive-aggressive/README.md diff --git a/23-passive-aggressive/tf-23.py b/21-passive-aggressive/tf-21.py similarity index 100% rename from 23-passive-aggressive/tf-23.py rename to 21-passive-aggressive/tf-21.py diff --git a/23-passive-aggressive/tf-23-monadic.py b/21-passive-aggressive/tf-23-monadic.py similarity index 100% rename from 23-passive-aggressive/tf-23-monadic.py rename to 21-passive-aggressive/tf-23-monadic.py diff --git a/24-declared-intentions/README.md b/22-declared-intentions/README.md similarity index 100% rename from 24-declared-intentions/README.md rename to 22-declared-intentions/README.md diff --git a/25-quarantine/README.md b/23-quarantine/README.md similarity index 100% rename from 25-quarantine/README.md rename to 23-quarantine/README.md diff --git a/25-quarantine/tf-25.py b/23-quarantine/tf-23.py similarity index 100% rename from 25-quarantine/tf-25.py rename to 23-quarantine/tf-23.py diff --git a/24-declared-intentions/tf-24.py b/24-declared-intentions/tf-24.py deleted file mode 100755 index 4ff79f4..0000000 --- a/24-declared-intentions/tf-24.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env python - -import sys, re, operator, string, inspect - -# -# Decorator for enforcing types of arguments in method calls -# -class AcceptTypes(): - def __init__(self, *args): - self._args = args - - def __call__(self, f): - def wrapped_f(*args): - for i in range(len(self._args)): - if type(args[i]) <> self._args[i]: - raise TypeError("Expecting %s got %s" % (str(self._args[i]), str(type(args[i])))) - - return f(*args) - return wrapped_f -# -# The functions -# -@AcceptTypes(str) -def extract_words(path_to_file): - """ - Takes a path to a file and returns the non-stop - words, after properly removing nonalphanumeric chars - and normalizing for lower case - """ - with open(path_to_file) as f: - str_data = f.read() - - pattern = re.compile('[\W_]+') - word_list = pattern.sub(' ', str_data).lower().split() - - with open('../stop_words.txt') as f: - stop_words = f.read().split(',') - - stop_words.extend(list(string.ascii_lowercase)) - return [w for w in word_list if not w in stop_words] - -@AcceptTypes(list) -def frequencies(word_list): - """ - Takes a list of words and returns a dictionary associating - words with frequencies of occurrence - """ - word_freqs = {} - for w in word_list: - if w in word_freqs: - word_freqs[w] += 1 - else: - word_freqs[w] = 1 - return word_freqs - -@AcceptTypes(dict) -def sort(word_freq): - """ - Takes a dictionary of words and their frequencies - and returns a list of pairs where the entries are - sorted by frequency - """ - return sorted(word_freq.iteritems(), key=operator.itemgetter(1), reverse=True) - -# -# The main function -# -word_freqs = sort(frequencies(extract_words(sys.argv[1]))) - -for tf in word_freqs[0:25]: - print tf[0], ' - ', tf[1] - diff --git a/26-spreadsheet/README.md b/24-spreadsheet/README.md similarity index 100% rename from 26-spreadsheet/README.md rename to 24-spreadsheet/README.md diff --git a/26-spreadsheet/tf-26.py b/24-spreadsheet/tf-24.py similarity index 100% rename from 26-spreadsheet/tf-26.py rename to 24-spreadsheet/tf-24.py diff --git a/27-tabular/README.md b/25-tabular/README.md similarity index 100% rename from 27-tabular/README.md rename to 25-tabular/README.md diff --git a/27-tabular/tf-27.py b/25-tabular/tf-25.py similarity index 100% rename from 27-tabular/tf-27.py rename to 25-tabular/tf-25.py diff --git a/28-lazy-rivers/README.md b/26-lazy-rivers/README.md similarity index 100% rename from 28-lazy-rivers/README.md rename to 26-lazy-rivers/README.md diff --git a/28-lazy-rivers/tf-28.py b/26-lazy-rivers/tf-26.py similarity index 100% rename from 28-lazy-rivers/tf-28.py rename to 26-lazy-rivers/tf-26.py diff --git a/15-free-agents/README.md b/27-free-agents/README.md similarity index 100% rename from 15-free-agents/README.md rename to 27-free-agents/README.md diff --git a/15-free-agents/tf-15.py b/27-free-agents/tf-27.py similarity index 100% rename from 15-free-agents/tf-15.py rename to 27-free-agents/tf-27.py diff --git a/16-dataspaces/README.md b/28-dataspaces/README.md similarity index 100% rename from 16-dataspaces/README.md rename to 28-dataspaces/README.md diff --git a/16-dataspaces/tf-16.py b/28-dataspaces/tf-28.py similarity index 100% rename from 16-dataspaces/tf-16.py rename to 28-dataspaces/tf-28.py