kotodama 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  require 'kaiseki'
2
2
 
3
3
  module Kotodama
4
- VERSION = '1.2.3'
4
+ VERSION = '1.2.4'
5
5
  file_path = File.dirname __FILE__
6
6
 
7
7
  #load base class mods
@@ -29,6 +29,7 @@ module Kotodama
29
29
  else
30
30
  string << n[0]
31
31
  end
32
+ string.gsub '$', ''
32
33
  end
33
34
  string
34
35
  end
@@ -0,0 +1,36 @@
1
+ module Kotodama
2
+ class Language
3
+ attr_reader :types, :rules, :changes, :spellings, :options, :zipf
4
+
5
+ def initialize
6
+ @types = {}
7
+ @rules = {}
8
+ @changes = {}
9
+ @spellings = {}
10
+ @options = {}
11
+ @zipf = {}
12
+ end
13
+
14
+ def generate options = {}
15
+ rule = options[:rule] || @options['$rule']
16
+ raise "rule `#{rule}' isn't defined" unless @rules.key? rule
17
+ output = @rules[rule].generate
18
+ return output.join if options[:generate_only]
19
+ change = options[:change] || @options['$change']
20
+ if change
21
+ raise "change `#{change}' isn't defined" unless @changes.key? change
22
+ output = @changes[change].apply self, output
23
+ end
24
+ return output.join if options[:change_only]
25
+ string = ''
26
+ output.each do |n|
27
+ if @spellings.key? n
28
+ string << @spellings[n]
29
+ else
30
+ string << n[0]
31
+ end
32
+ end
33
+ string
34
+ end
35
+ end
36
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: kotodama
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.2.3
5
+ version: 1.2.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - William Hamilton-Levi
@@ -40,6 +40,7 @@ files:
40
40
  - lib/mod_array.rb
41
41
  - lib/kotodama_grammar.rb~
42
42
  - lib/language.rb
43
+ - lib/language.rb~
43
44
  - lib/kotodama.rb
44
45
  - lib/kotodama_grammar.rb
45
46
  - README