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 +4 -4
- data/README.md +7 -0
- data/lib/demystify/version.rb +1 -1
- data/lib/demystify.rb +12 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2008bae5fd3de5d608e3be677c79d2161c22395
|
4
|
+
data.tar.gz: 73a508eec35acfd344190acc4087e147677301c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/demystify/version.rb
CHANGED
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
|