Skip to content

Instantly share code, notes, and snippets.

@olabini
Forked from samaaron/gist:257080
Created December 15, 2009 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olabini/257236 to your computer and use it in GitHub Desktop.
Save olabini/257236 to your computer and use it in GitHub Desktop.
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