markovite 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/markovite.rb +15 -0
- data/lib/markovite/version.rb +1 -1
- data/pkg/markovite-0.2.2.gem +0 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9228ae1173249e835b7a51bff00e748a4cda2a134592a3bf630bbc55320fcbe1
|
4
|
+
data.tar.gz: 51d7fca721c7598b77185ad7729176b1c60957889d53a8be70d6d1865b670b5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b83bc1f1b4995779073a53ec19a542c80e6aac02a3995b44f51d16e875fbe12137fb540aabdfc7c4b03e65ff79e3322a3fc8fff60f6b4937bf1e6c7899b22e3f
|
7
|
+
data.tar.gz: 55826f34f74b4c2cf8cf7cdd9a07310b7466927424d478da49e2ddf2b09455469d128f1e1513561f58261471e8cb67a626d58720bf7d4b820fbefdd36ef217ce
|
data/Gemfile.lock
CHANGED
data/lib/markovite.rb
CHANGED
@@ -5,6 +5,8 @@ module Markovite
|
|
5
5
|
class Chain
|
6
6
|
attr_accessor :dictionary, :chainer, :split
|
7
7
|
attr_reader :depth
|
8
|
+
MIN_DEPTH = 1
|
9
|
+
MAX_DEPTH = 4
|
8
10
|
DEFAULT_DEPTH = 2
|
9
11
|
MAX_FILENAME_LENGTH = 255
|
10
12
|
|
@@ -13,6 +15,7 @@ module Markovite
|
|
13
15
|
end
|
14
16
|
|
15
17
|
def parse_string(text, dict_depth=DEFAULT_DEPTH)
|
18
|
+
depth_check(dict_depth)
|
16
19
|
if chainer
|
17
20
|
add_from_text(text)
|
18
21
|
else
|
@@ -58,6 +61,18 @@ module Markovite
|
|
58
61
|
|
59
62
|
private
|
60
63
|
|
64
|
+
def depth_check(dict_depth)
|
65
|
+
if chainer
|
66
|
+
raise "Chain depth conflict" if dict_depth != depth
|
67
|
+
elsif !is_valid_depth?(dict_depth)
|
68
|
+
raise "Chain depth must be between #{MIN_DEPTH} and #{MAX_DEPTH}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def is_valid_depth?(dict_depth)
|
73
|
+
dict_depth >= MIN_DEPTH && dict_depth <= MAX_DEPTH
|
74
|
+
end
|
75
|
+
|
61
76
|
def split_words(str)
|
62
77
|
str.split(" ")
|
63
78
|
end
|
data/lib/markovite/version.rb
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markovite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandra Wright
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- lib/markovite/splitter.rb
|
93
93
|
- lib/markovite/version.rb
|
94
94
|
- markovite.gemspec
|
95
|
+
- pkg/markovite-0.2.2.gem
|
95
96
|
homepage: https://github.com/f3mshep/ruby_markovify
|
96
97
|
licenses:
|
97
98
|
- MIT
|