wordstats 1.0.0 → 1.0.1
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/lib/wordstats.rb +9 -7
- data/lib/wordstats/version.rb +1 -1
- data/wordstats-1.0.0.gem +0 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 468979e402beb05a610123af7211cec9cc86be12
|
4
|
+
data.tar.gz: 2849026cca7451e51de89ce49783971f785f7ea7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18670a1ef1180ae1ff41428503348e08b9a9b08384725f12356dda5bfb96c8df69880b87c9ea75f39b94aa4c54773e1cc16d511207c29329422cc201d06efa8e
|
7
|
+
data.tar.gz: 8347282af1b8ad75da47379b01ee1e22c03cae70e11cd8d07412c890f93ec0e1f2be3b88a9decfe79fcfdf97862760fe49c090d32a0515174bfabbc9dda5129f
|
data/lib/wordstats.rb
CHANGED
@@ -8,11 +8,11 @@ class Wordstats
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def process(str)
|
11
|
-
word_count(str)
|
12
|
-
avg_word_length(str)
|
13
|
-
most_common_noun(str)
|
14
|
-
most_common_word(str)
|
15
|
-
avg_sentence_length(str)
|
11
|
+
p "Word Count: " + word_count(str).to_s
|
12
|
+
p "Average Word Length: " + avg_word_length(str).to_s
|
13
|
+
p "Most Common Noun: " + most_common_noun(str).to_s
|
14
|
+
p "Most Common Word: " + most_common_word(str).to_s
|
15
|
+
p "Average Sentence Length: " + avg_sentence_length(str).to_s + " words"
|
16
16
|
end
|
17
17
|
|
18
18
|
def word_count(str)
|
@@ -26,7 +26,8 @@ class Wordstats
|
|
26
26
|
word_arr.each do |word|
|
27
27
|
word_length_arr << word.length
|
28
28
|
end
|
29
|
-
word_length_arr.reduce(:+)
|
29
|
+
sum = word_length_arr.reduce(:+)
|
30
|
+
sum / word_length_arr.length
|
30
31
|
end
|
31
32
|
|
32
33
|
def most_common_noun(str)
|
@@ -72,7 +73,8 @@ class Wordstats
|
|
72
73
|
word_arr = sentence.split(' ')
|
73
74
|
sentence_length_arr << word_arr.length
|
74
75
|
end
|
75
|
-
sentence_length_arr.reduce(:+)
|
76
|
+
sum = sentence_length_arr.reduce(:+)
|
77
|
+
sum / sentence_length_arr.length
|
76
78
|
end
|
77
79
|
|
78
80
|
end
|
data/lib/wordstats/version.rb
CHANGED
data/wordstats-1.0.0.gem
ADDED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wordstats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Niu
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- bin/setup
|
87
87
|
- lib/wordstats.rb
|
88
88
|
- lib/wordstats/version.rb
|
89
|
+
- wordstats-1.0.0.gem
|
89
90
|
- wordstats.gemspec
|
90
91
|
homepage: https://github.com/kevniu/Word-Stats
|
91
92
|
licenses:
|