words_counted 1.0.1 → 1.0.2
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/words_counted.rb +20 -2
- data/lib/words_counted/counter.rb +0 -3
- data/lib/words_counted/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9596a5852bcc4c417a62f4ec4aa2153eed7d4297
|
4
|
+
data.tar.gz: fad6c9456601aff8c709b1a385d9638e68140ac5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0891409f8b63f89527fd68e8fed3ef2f917b9b342a0aabd6a00479627bea4ef2e9552810a25a4fd103529bc8cda846b9b50624c91437c0cf6a94b7e4e316c6c
|
7
|
+
data.tar.gz: 36c3c925b20388d86a5ef582e9ad09ca74b1f9fda8a9a66113ed5783d5123b2d99db342450a54e76278b41990c1301c6e31750ee7c5072aacf21e544147cd82c
|
data/lib/words_counted.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
require "refinements/hash_refinements"
|
3
3
|
|
4
|
+
require "words_counted/deprecated"
|
5
|
+
|
4
6
|
require "words_counted/tokeniser"
|
5
7
|
require "words_counted/counter"
|
6
8
|
require "words_counted/version"
|
@@ -11,11 +13,27 @@ rescue LoadError
|
|
11
13
|
end
|
12
14
|
|
13
15
|
module WordsCounted
|
14
|
-
|
15
|
-
|
16
|
+
# Takes a string, tokenises it, and returns an instance of Counter
|
17
|
+
# with the resulting tokens.
|
18
|
+
#
|
19
|
+
# @see Tokeniser.tokenise
|
20
|
+
# @see Counter.initialize
|
21
|
+
#
|
22
|
+
# @param [String] input The input to be tokenised.
|
23
|
+
# @param [Hash] options The options to pass onto `Counter`.
|
24
|
+
def self.count(input, options = {})
|
25
|
+
tokens = Tokeniser.new(input).tokenise(options)
|
16
26
|
Counter.new(tokens)
|
17
27
|
end
|
18
28
|
|
29
|
+
# Takes a file path, reads the file and tokenises its contents,
|
30
|
+
# and returns an instance of Counter with the resulting tokens.
|
31
|
+
#
|
32
|
+
# @see Tokeniser.tokenise
|
33
|
+
# @see Counter.initialize
|
34
|
+
#
|
35
|
+
# @param [String] path The file to be read and tokenised.
|
36
|
+
# @param [Hash] options The options to pass onto `Counter`.
|
19
37
|
def self.from_file(path, options = {})
|
20
38
|
tokens = File.open(path) do |file|
|
21
39
|
Tokeniser.new(file.read).tokenise(options)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: words_counted
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mohamad El-Husseini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|