Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. require 'json'
  2.  
  3. all_chars = {}
  4.  
  5. Dir['**/*.md'].each do |file|
  6. character_data = IO.read(file).each_char.each_with_object(Hash.new(0)) do |word, counts|
  7. counts[word] += 1
  8. end
  9.  
  10. all_chars.merge!(character_data) do |_, oldval, newval|
  11. oldval + newval
  12. end
  13. end
  14.  
  15. puts all_chars.to_json
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement