moo_ebooks 1.0.2 → 1.1.0
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 +5 -5
- data/README.md +7 -1
- data/lib/moo_ebooks/model.rb +32 -3
- data/lib/moo_ebooks/version.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ca3871121fb9d2f07baf2afa539686b46a7f1d8c
|
4
|
+
data.tar.gz: 6b219bdc101f8620b8e5ff827165835ffc5065c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 917a354b63c9549569e0bd7141261d22d2d39488c6b85d2f928c44da3b2f36b2039ce151995610f3657223c7e8adf3a8d4f6c574308c159f8f627cfe643175b5
|
7
|
+
data.tar.gz: ff0784492e5c5cbf3a905bf5ec946cdede1235cc061b04ca7cb8a089f3488e862e0177febd92f35a054bd27cdc723e971ffd975899d7d35692314c1a797242c8
|
data/README.md
CHANGED
@@ -34,8 +34,14 @@ or simply run `gem install moo_ebooks`
|
|
34
34
|
|
35
35
|
## Example usage code
|
36
36
|
|
37
|
+
Say, for example, we have a json file full of statuses in 'statuses.json'. These statuses are arranged so that there is an array of strings with the key ':statuses'. The following code will read that file in, create a model based off of it and print out a randomly generated status based off of them.
|
38
|
+
|
37
39
|
``` ruby
|
38
|
-
|
40
|
+
require 'moo_ebooks'
|
41
|
+
|
42
|
+
Model = Ebooks::Model.from_json(File.read('statuses.json'))
|
43
|
+
|
44
|
+
Model.update
|
39
45
|
```
|
40
46
|
|
41
47
|
## Versioning
|
data/lib/moo_ebooks/model.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'json'
|
4
|
+
require 'yaml'
|
4
5
|
require 'set'
|
5
6
|
require 'digest/md5'
|
6
7
|
|
@@ -41,6 +42,13 @@ module Ebooks
|
|
41
42
|
@tikis = {}
|
42
43
|
end
|
43
44
|
|
45
|
+
# Load a saved model
|
46
|
+
# @param data [String]
|
47
|
+
# @return [Ebooks::Model]
|
48
|
+
def self.from_yaml(data)
|
49
|
+
from_hash(YAML.load(data))
|
50
|
+
end
|
51
|
+
|
44
52
|
# Load a saved model
|
45
53
|
# @param data [Hash]
|
46
54
|
# @return [Ebooks::Model]
|
@@ -60,6 +68,11 @@ module Ebooks
|
|
60
68
|
from_hash(JSON.parse(data, symbolize_names: true))
|
61
69
|
end
|
62
70
|
|
71
|
+
# Turn this model into its YAML representation.
|
72
|
+
def to_yaml
|
73
|
+
to_hash.to_yaml
|
74
|
+
end
|
75
|
+
|
63
76
|
# Turn this model into its JSON representation.
|
64
77
|
def to_json
|
65
78
|
to_hash.to_json
|
@@ -218,8 +231,20 @@ module Ebooks
|
|
218
231
|
end
|
219
232
|
|
220
233
|
text = statuses.join("\n").encode('UTF-8', invalid: :replace)
|
221
|
-
|
222
|
-
|
234
|
+
|
235
|
+
# adds the new sentence structures into the sentence array
|
236
|
+
# instead of overwriting it
|
237
|
+
mass_tikify(text).each do |sentence|
|
238
|
+
@sentences << sentence
|
239
|
+
end
|
240
|
+
|
241
|
+
# if we're gonna keep the keyword limit at 200 and we want to preserve
|
242
|
+
# our old keywords array then my solution is to union the new array
|
243
|
+
# with the old, randomize them and take the first 200
|
244
|
+
@keywords = @keywords.union(NLP
|
245
|
+
.keywords(text)
|
246
|
+
.top(200)
|
247
|
+
.map(&:to_s)).sample(200)
|
223
248
|
|
224
249
|
nil
|
225
250
|
end
|
@@ -232,7 +257,11 @@ module Ebooks
|
|
232
257
|
end
|
233
258
|
|
234
259
|
mention_text = mentions.join("\n").encode('UTF-8', invalid: :replace)
|
235
|
-
|
260
|
+
# the same as above, we just add onto our array instead of
|
261
|
+
# overwriting it
|
262
|
+
mass_tikify(mention_text).each do |mention|
|
263
|
+
@mentions << mention
|
264
|
+
end
|
236
265
|
|
237
266
|
nil
|
238
267
|
end
|
data/lib/moo_ebooks/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moo_ebooks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jaiden Mispy
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-07-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
148
|
version: '0'
|
149
149
|
requirements: []
|
150
150
|
rubyforge_project:
|
151
|
-
rubygems_version: 2.
|
151
|
+
rubygems_version: 2.5.2.1
|
152
152
|
signing_key:
|
153
153
|
specification_version: 4
|
154
154
|
summary: A minimalistic ebook library
|