Blame view

examples/entropy.rb 356 Bytes
845768f8a   Romain Deveaud   creating a group ...
1
  require 'mirimiri'
3e81fa06a   Romain Deveaud   an entropy comput...
2
3
4
5
6
7
  
  # Concatenates all lines from one file, without 
  
  readme = File.open('README.markdown').readlines.collect { |l| l.chomp }.join(" ")
  
  # Creates the document with a string
845768f8a   Romain Deveaud   creating a group ...
8
  doc = Mirimiri::Document.new readme
3e81fa06a   Romain Deveaud   an entropy comput...
9
10
11
  
  # Outputs all the unique words of the document with their entropy scores
  p doc.words.collect { |w| "#{w} => #{doc.entropy w}" }