frequency_analyser 1.2.0 → 1.2.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.
- data/README.md +13 -7
- metadata +3 -3
data/README.md
CHANGED
@@ -14,10 +14,10 @@ require 'frequency_analyser'
|
|
14
14
|
file = File.new('a_tale_of_two_cities.txt')
|
15
15
|
FrequencyAnalyser.analyse(file)
|
16
16
|
#=> {
|
17
|
-
'a'=>47063, 'b'=>8139,
|
18
|
-
'g'=>12121, 'h'=>38358, 'i'=>39784, 'j'=>622,
|
19
|
-
'm'=>14922, 'n'=>41310, 'o'=>45115, 'p'=>9453,
|
20
|
-
's'=>36771, 't'=>52393, 'u'=>16216, 'v'=>5065,
|
17
|
+
'a'=>47063, 'b'=>8139, 'c'=>13224, 'd'=>27484, 'e'=>72877, 'f'=>13152,
|
18
|
+
'g'=>12121, 'h'=>38358, 'i'=>39784, 'j'=>622, 'k'=>4634, 'l'=>21533,
|
19
|
+
'm'=>14922, 'n'=>41310, 'o'=>45115, 'p'=>9453, 'q'=>655, 'r'=>35956,
|
20
|
+
's'=>36771, 't'=>52393, 'u'=>16216, 'v'=>5065, 'w'=>13835, 'x'=>666,
|
21
21
|
'y'=>11849, 'z'=>213
|
22
22
|
}
|
23
23
|
```
|
@@ -42,14 +42,14 @@ If you'd like to calculate the frequency probabilities instead, you can pass in
|
|
42
42
|
|
43
43
|
```ruby
|
44
44
|
FrequencyAnalyser.analyse('Hello, world!', :probability)
|
45
|
-
|
45
|
+
#=> { 'd'=>0.1, 'e'=>0.1, 'h'=>0.1, 'l'=>0.3, 'o'=>0.2, 'r'=>0.1, 'w'=>0.1 }
|
46
46
|
```
|
47
47
|
|
48
48
|
The same goes for percentages:
|
49
49
|
|
50
50
|
```ruby
|
51
|
-
FrequencyAnalyser.analyse('Hello, world!', :
|
52
|
-
|
51
|
+
FrequencyAnalyser.analyse('Hello, world!', :percentage)
|
52
|
+
#=> { 'd'=>10, 'e'=>10, 'h'=>10, 'l'=>30, 'o'=>20, 'r'=>10, 'w'=>10 }
|
53
53
|
```
|
54
54
|
|
55
55
|
## Counting other things
|
@@ -67,3 +67,9 @@ analyser.analyse('!12321!')
|
|
67
67
|
```
|
68
68
|
|
69
69
|
Most of the gem is architected in this way, so it should be straightforward to add new modes, for example.
|
70
|
+
|
71
|
+
## Contribution
|
72
|
+
|
73
|
+
Feel free. No pull request is too small.
|
74
|
+
|
75
|
+
You should follow me: [@cpatuzzo](https://twitter.com/#!/cpatuzzo)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frequency_analyser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 1
|
10
|
+
version: 1.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Christopher Patuzzo
|