demystify 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f866b0db80a39f4ffa18d4b3a7c7b883a0652441
4
- data.tar.gz: 533a739dae1f5b6d8f6993f42fc00f61a35d9913
3
+ metadata.gz: d2008bae5fd3de5d608e3be677c79d2161c22395
4
+ data.tar.gz: 73a508eec35acfd344190acc4087e147677301c3
5
5
  SHA512:
6
- metadata.gz: b30370b6689c4e43b6afcaf91c98cbca58e4736314887cc289b3f6c237f83308166e9470172be7dcd170a2a81987d8f3211d450c574f9b6e543c9ce57b87490a
7
- data.tar.gz: c1e1adba246288c5e4bdace424b3a8bf9588819567d2d3ff2670074b6a7c290474fdb91a89ee2c562a56428c033bffbd3cf6beebc089b193dc1a10ae3928bcf0
6
+ metadata.gz: 837386e0d03317044acc05033292ade1ebe9c0dd75f6d656e6254c4682f728f44fef36ad90aa34585938ca27f680af84661e0d5c761323c3b44abdc85706c11d
7
+ data.tar.gz: 6cda8a7243d518eba10ca6707be5812452aee01e237d356262d1e8ae241208673699d87fe55cfc84e798053fe46b7c7cbdedf54d764cff7f1aad949bc62dbdf9
data/README.md CHANGED
@@ -58,6 +58,13 @@ text.first_words
58
58
  text.last_words
59
59
  ```
60
60
 
61
+ Get the average length of a word or average number of words per sentence:
62
+ ```ruby
63
+ text.average_word_length
64
+ text.average_sentence_length
65
+ ```
66
+
67
+
61
68
  Get a hash of every word in the text of pointing to an array of all of its following or preceding words in the text:
62
69
  ```ruby
63
70
  text.forwards_probability_hash
@@ -1,3 +1,3 @@
1
1
  module Demystify
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/demystify.rb CHANGED
@@ -115,6 +115,18 @@ module Demystify
115
115
  @sentences.length
116
116
  end
117
117
 
118
+ def average_word_length
119
+ total_length = 0
120
+ @words.each do |word|
121
+ total_length += word.length
122
+ end
123
+ total_length / word_count
124
+ end
125
+
126
+ def average_sentence_length
127
+ word_count / sentence_count
128
+ end
129
+
118
130
  private
119
131
 
120
132
  def make_first_and_last_words
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: demystify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - DouglasTGordon