Created
December 15, 2009 16:53
-
-
Save samaaron/257080 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
counts = method( | |
files_to_read = FileSystem["**"] reject(name, FileSystem directory?(name)) | |
combined_text = files_to_read map(filename, FileSystem readFully(filename)) join("") | |
filtered_words = #/\w+/ allMatches(combined_text) map(lower) | |
filtered_words inject({} withDefault(0), counts, word, counts[word]++. counts) | |
) | |
spit = method(outfile, enumerable, | |
FileSystem withOpenFile(outfile, fn(file, enumerable each(x, file println(x))))) | |
spit("alphabetical_output_ioke.txt", counts sort) | |
spit("count_output_ioke.txt", counts sortBy(value)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment