markov-reloaded 0.0.2 → 0.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.
Files changed (2) hide show
  1. data/lib/markov-reloaded.rb +18 -4
  2. metadata +5 -3
@@ -102,11 +102,25 @@ class Markov
102
102
  pick = out.dup
103
103
  for i in 0..(maxlength-@order)
104
104
  element = pickElement(pick, r)
105
- out.push element
106
- pick = pick.drop 1
107
- pick.push element
105
+ if out.class == Array
106
+ out.push element
107
+ elsif out.class == String
108
+ out += element
109
+ end
110
+ if pick.class == Array
111
+ pick = pick.drop 1
112
+ elsif pick.class == String
113
+ pick = pick[1..pick.length-1]
114
+ end
115
+ if pick.class == Array
116
+ pick.push element
117
+ elsif pick.class == String
118
+ pick += element
119
+ end
108
120
  break if element == terminator
109
121
  end
110
122
  return out
111
123
  end
112
- end
124
+ end
125
+ mark = Markov.analyze("James.Smith.John.Carl.Joseph.Robert.Matthew.Magnus.Eric.Gregory.", 1)
126
+ print mark.generate(50, [], Time.now.nsec, ".")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markov-reloaded
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,13 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-23 00:00:00.000000000 Z
12
+ date: 2012-08-24 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! "markov-reloaded provides a simple interface to create markov chains.\n\tthe
15
15
  system is based on hashes, but provides flexible methods to generate the chains
16
- based on any array, and to generate suitable arrays from strings."
16
+ based on any array, and to generate suitable arrays from strings.\n\tIn addition,
17
+ version 0.1.0 extends functionality, letting one input strings instead of arrays
18
+ directly into the analyze method(treating each character\n\t\tas an element"
17
19
  email: ayegill@gmail.com
18
20
  executables: []
19
21
  extensions: []