ruby_speech 2.1.2-java → 2.2.0-java
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.
- data/.travis.yml +1 -2
- data/CHANGELOG.md +8 -0
- data/README.md +23 -0
- data/ext/ruby_speech/extconf.rb +3 -1
- data/ext/ruby_speech/ruby_speech.c +4 -1
- data/lib/ruby_speech/generic_element.rb +141 -29
- data/lib/ruby_speech/grxml/element.rb +6 -6
- data/lib/ruby_speech/grxml/grammar.rb +29 -12
- data/lib/ruby_speech/grxml/item.rb +13 -0
- data/lib/ruby_speech/grxml/matcher.rb +5 -1
- data/lib/ruby_speech/grxml/one_of.rb +4 -0
- data/lib/ruby_speech/grxml/rule.rb +10 -0
- data/lib/ruby_speech/grxml/token.rb +3 -0
- data/lib/ruby_speech/grxml.rb +16 -22
- data/lib/ruby_speech/nlsml.rb +3 -9
- data/lib/ruby_speech/ruby_speech.jar +0 -0
- data/lib/ruby_speech/ssml/audio.rb +17 -0
- data/lib/ruby_speech/ssml/desc.rb +4 -0
- data/lib/ruby_speech/ssml/element.rb +5 -3
- data/lib/ruby_speech/ssml/emphasis.rb +17 -0
- data/lib/ruby_speech/ssml/mark.rb +2 -0
- data/lib/ruby_speech/ssml/p.rb +21 -0
- data/lib/ruby_speech/ssml/phoneme.rb +2 -0
- data/lib/ruby_speech/ssml/prosody.rb +15 -0
- data/lib/ruby_speech/ssml/s.rb +20 -0
- data/lib/ruby_speech/ssml/say_as.rb +2 -0
- data/lib/ruby_speech/ssml/speak.rb +19 -1
- data/lib/ruby_speech/ssml/sub.rb +2 -0
- data/lib/ruby_speech/ssml/voice.rb +19 -0
- data/lib/ruby_speech/ssml.rb +20 -22
- data/lib/ruby_speech/version.rb +1 -1
- data/lib/ruby_speech.rb +6 -19
- data/ruby_speech.gemspec +2 -3
- data/spec/ruby_speech/grxml/grammar_spec.rb +35 -30
- data/spec/ruby_speech/grxml/item_spec.rb +8 -6
- data/spec/ruby_speech/grxml/one_of_spec.rb +7 -3
- data/spec/ruby_speech/grxml/rule_spec.rb +14 -12
- data/spec/ruby_speech/grxml/ruleref_spec.rb +5 -3
- data/spec/ruby_speech/grxml/tag_spec.rb +6 -2
- data/spec/ruby_speech/grxml/token_spec.rb +6 -2
- data/spec/ruby_speech/grxml_spec.rb +57 -69
- data/spec/ruby_speech/ssml/audio_spec.rb +20 -16
- data/spec/ruby_speech/ssml/break_spec.rb +14 -10
- data/spec/ruby_speech/ssml/desc_spec.rb +9 -5
- data/spec/ruby_speech/ssml/emphasis_spec.rb +17 -13
- data/spec/ruby_speech/ssml/mark_spec.rb +7 -3
- data/spec/ruby_speech/ssml/p_spec.rb +18 -14
- data/spec/ruby_speech/ssml/phoneme_spec.rb +10 -6
- data/spec/ruby_speech/ssml/prosody_spec.rb +29 -25
- data/spec/ruby_speech/ssml/s_spec.rb +17 -13
- data/spec/ruby_speech/ssml/say_as_spec.rb +11 -7
- data/spec/ruby_speech/ssml/speak_spec.rb +48 -32
- data/spec/ruby_speech/ssml/sub_spec.rb +9 -5
- data/spec/ruby_speech/ssml/voice_spec.rb +23 -19
- data/spec/ruby_speech/ssml_spec.rb +64 -63
- data/spec/spec_helper.rb +0 -3
- metadata +12 -35
- data/lib/ruby_speech/xml.rb +0 -11
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'ruby_speech/ssml/element'
|
2
|
+
|
1
3
|
module RubySpeech
|
2
4
|
module SSML
|
3
5
|
##
|
@@ -7,6 +9,21 @@ module RubySpeech
|
|
7
9
|
#
|
8
10
|
class Emphasis < Element
|
9
11
|
|
12
|
+
%w{
|
13
|
+
audio
|
14
|
+
break
|
15
|
+
desc
|
16
|
+
mark
|
17
|
+
p
|
18
|
+
phoneme
|
19
|
+
prosody
|
20
|
+
s
|
21
|
+
say_as
|
22
|
+
speak
|
23
|
+
sub
|
24
|
+
voice
|
25
|
+
}.each { |f| require "ruby_speech/ssml/#{f}" }
|
26
|
+
|
10
27
|
register :emphasis
|
11
28
|
|
12
29
|
VALID_LEVELS = [:strong, :moderate, :none, :reduced].freeze
|
data/lib/ruby_speech/ssml/p.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'ruby_speech/ssml/element'
|
2
|
+
require 'ruby_speech/xml/language'
|
3
|
+
|
1
4
|
module RubySpeech
|
2
5
|
module SSML
|
3
6
|
##
|
@@ -8,6 +11,24 @@ module RubySpeech
|
|
8
11
|
#
|
9
12
|
class P < Element
|
10
13
|
|
14
|
+
%w{
|
15
|
+
audio
|
16
|
+
break
|
17
|
+
desc
|
18
|
+
element
|
19
|
+
emphasis
|
20
|
+
mark
|
21
|
+
phoneme
|
22
|
+
prosody
|
23
|
+
s
|
24
|
+
say_as
|
25
|
+
speak
|
26
|
+
sub
|
27
|
+
voice
|
28
|
+
}.each { |f| require "ruby_speech/ssml/#{f}" }
|
29
|
+
|
30
|
+
include XML::Language
|
31
|
+
|
11
32
|
register :p
|
12
33
|
|
13
34
|
VALID_CHILD_TYPES = [Nokogiri::XML::Element, Nokogiri::XML::Text, String, Audio, Break, Emphasis, Mark, Phoneme, Prosody, S, SayAs, Sub, Voice].freeze
|
@@ -13,6 +13,21 @@ module RubySpeech
|
|
13
13
|
#
|
14
14
|
class Prosody < Element
|
15
15
|
|
16
|
+
%w{
|
17
|
+
audio
|
18
|
+
break
|
19
|
+
desc
|
20
|
+
emphasis
|
21
|
+
mark
|
22
|
+
p
|
23
|
+
phoneme
|
24
|
+
s
|
25
|
+
say_as
|
26
|
+
speak
|
27
|
+
sub
|
28
|
+
voice
|
29
|
+
}.each { |f| require "ruby_speech/ssml/#{f}" }
|
30
|
+
|
16
31
|
register :prosody
|
17
32
|
|
18
33
|
VALID_PITCHES = [:'x-low', :low, :medium, :high, :'x-high', :default].freeze
|
data/lib/ruby_speech/ssml/s.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'ruby_speech/ssml/element'
|
2
|
+
require 'ruby_speech/xml/language'
|
3
|
+
|
1
4
|
module RubySpeech
|
2
5
|
module SSML
|
3
6
|
##
|
@@ -8,6 +11,23 @@ module RubySpeech
|
|
8
11
|
#
|
9
12
|
class S < Element
|
10
13
|
|
14
|
+
%w{
|
15
|
+
audio
|
16
|
+
break
|
17
|
+
desc
|
18
|
+
emphasis
|
19
|
+
mark
|
20
|
+
p
|
21
|
+
phoneme
|
22
|
+
prosody
|
23
|
+
say_as
|
24
|
+
speak
|
25
|
+
sub
|
26
|
+
voice
|
27
|
+
}.each { |f| require "ruby_speech/ssml/#{f}" }
|
28
|
+
|
29
|
+
include XML::Language
|
30
|
+
|
11
31
|
register :s
|
12
32
|
|
13
33
|
VALID_CHILD_TYPES = [Nokogiri::XML::Element, Nokogiri::XML::Text, String, Audio, Break, Emphasis, Mark, Phoneme, Prosody, SayAs, Sub, Voice].freeze
|
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'ruby_speech/ssml/element'
|
2
|
+
require 'ruby_speech/xml/language'
|
3
|
+
|
1
4
|
module RubySpeech
|
2
5
|
module SSML
|
3
6
|
##
|
@@ -6,11 +9,26 @@ module RubySpeech
|
|
6
9
|
# http://www.w3.org/TR/speech-synthesis/#S3.1.1
|
7
10
|
#
|
8
11
|
class Speak < Element
|
12
|
+
|
13
|
+
%w{
|
14
|
+
audio
|
15
|
+
break
|
16
|
+
desc
|
17
|
+
emphasis
|
18
|
+
mark
|
19
|
+
phoneme
|
20
|
+
prosody
|
21
|
+
s
|
22
|
+
say_as
|
23
|
+
sub
|
24
|
+
voice
|
25
|
+
}.each { |f| require "ruby_speech/ssml/#{f}" }
|
26
|
+
|
9
27
|
include XML::Language
|
10
28
|
|
11
29
|
register :speak
|
12
30
|
|
13
|
-
self.defaults = { :version => '1.0', :language => "en-US" }
|
31
|
+
self.defaults = { :version => '1.0', :language => "en-US", namespace: SSML_NAMESPACE }
|
14
32
|
|
15
33
|
VALID_CHILD_TYPES = [Nokogiri::XML::Element, Nokogiri::XML::Text, String, Audio, Break, Emphasis, Mark, P, Phoneme, Prosody, S, SayAs, Sub, Voice].freeze
|
16
34
|
|
data/lib/ruby_speech/ssml/sub.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'ruby_speech/ssml/element'
|
2
|
+
require 'ruby_speech/xml/language'
|
3
|
+
|
1
4
|
module RubySpeech
|
2
5
|
module SSML
|
3
6
|
##
|
@@ -6,6 +9,22 @@ module RubySpeech
|
|
6
9
|
# http://www.w3.org/TR/speech-synthesis/#S3.2.1
|
7
10
|
#
|
8
11
|
class Voice < Element
|
12
|
+
|
13
|
+
%w{
|
14
|
+
audio
|
15
|
+
break
|
16
|
+
desc
|
17
|
+
emphasis
|
18
|
+
mark
|
19
|
+
p
|
20
|
+
phoneme
|
21
|
+
prosody
|
22
|
+
s
|
23
|
+
say_as
|
24
|
+
speak
|
25
|
+
sub
|
26
|
+
}.each { |f| require "ruby_speech/ssml/#{f}" }
|
27
|
+
|
9
28
|
include XML::Language
|
10
29
|
|
11
30
|
register :voice
|
data/lib/ruby_speech/ssml.rb
CHANGED
@@ -1,30 +1,30 @@
|
|
1
1
|
module RubySpeech
|
2
2
|
module SSML
|
3
|
-
extend ActiveSupport::Autoload
|
4
|
-
|
5
|
-
eager_autoload do
|
6
|
-
autoload :Audio
|
7
|
-
autoload :Break
|
8
|
-
autoload :Desc
|
9
|
-
autoload :Element
|
10
|
-
autoload :Emphasis
|
11
|
-
autoload :Mark
|
12
|
-
autoload :P
|
13
|
-
autoload :Phoneme
|
14
|
-
autoload :Prosody
|
15
|
-
autoload :S
|
16
|
-
autoload :SayAs
|
17
|
-
autoload :Speak
|
18
|
-
autoload :Sub
|
19
|
-
autoload :Voice
|
20
|
-
end
|
21
|
-
|
22
3
|
InvalidChildError = Class.new StandardError
|
23
4
|
|
24
5
|
SSML_NAMESPACE = 'http://www.w3.org/2001/10/synthesis'
|
25
6
|
|
7
|
+
%w{
|
8
|
+
audio
|
9
|
+
break
|
10
|
+
desc
|
11
|
+
element
|
12
|
+
emphasis
|
13
|
+
mark
|
14
|
+
p
|
15
|
+
phoneme
|
16
|
+
prosody
|
17
|
+
s
|
18
|
+
say_as
|
19
|
+
speak
|
20
|
+
sub
|
21
|
+
voice
|
22
|
+
}.each { |f| require "ruby_speech/ssml/#{f}" }
|
23
|
+
|
26
24
|
def self.draw(*args, &block)
|
27
|
-
|
25
|
+
document = Nokogiri::XML::Document.new
|
26
|
+
Speak.new(document, *args).tap do |speak|
|
27
|
+
document.root = speak.node
|
28
28
|
block_return = speak.eval_dsl_block &block
|
29
29
|
speak << block_return if block_return.is_a?(String)
|
30
30
|
end
|
@@ -35,5 +35,3 @@ module RubySpeech
|
|
35
35
|
end
|
36
36
|
end # SSML
|
37
37
|
end # RubySpeech
|
38
|
-
|
39
|
-
ActiveSupport::Autoload.eager_autoload!
|
data/lib/ruby_speech/version.rb
CHANGED
data/lib/ruby_speech.rb
CHANGED
@@ -1,24 +1,13 @@
|
|
1
1
|
%w{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
nokogiri
|
3
|
+
|
4
|
+
ruby_speech/version
|
5
|
+
ruby_speech/ssml
|
6
|
+
ruby_speech/grxml
|
7
|
+
ruby_speech/nlsml
|
7
8
|
}.each { |f| require f }
|
8
9
|
|
9
10
|
module RubySpeech
|
10
|
-
extend ActiveSupport::Autoload
|
11
|
-
|
12
|
-
autoload :Version
|
13
|
-
|
14
|
-
eager_autoload do
|
15
|
-
autoload :GenericElement
|
16
|
-
autoload :SSML
|
17
|
-
autoload :GRXML
|
18
|
-
autoload :NLSML
|
19
|
-
autoload :XML
|
20
|
-
end
|
21
|
-
|
22
11
|
def self.parse(string)
|
23
12
|
document = Nokogiri::XML.parse string, nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS
|
24
13
|
namespace = document.root.namespace
|
@@ -32,5 +21,3 @@ module RubySpeech
|
|
32
21
|
end
|
33
22
|
end
|
34
23
|
end
|
35
|
-
|
36
|
-
ActiveSupport::Autoload.eager_autoload!
|
data/ruby_speech.gemspec
CHANGED
@@ -25,9 +25,8 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.extensions = ['ext/ruby_speech/extconf.rb']
|
26
26
|
end
|
27
27
|
|
28
|
-
s.add_runtime_dependency %q<
|
29
|
-
s.add_runtime_dependency %q<
|
30
|
-
s.add_runtime_dependency %q<activesupport>, [">= 3.0.7"]
|
28
|
+
s.add_runtime_dependency %q<nokogiri>, ["~> 1.6"]
|
29
|
+
s.add_runtime_dependency %q<activesupport>, [">= 3.0.7", "< 5.0.0"]
|
31
30
|
|
32
31
|
s.add_development_dependency %q<bundler>, [">= 1.0.0"]
|
33
32
|
s.add_development_dependency %q<rspec>, [">= 2.7"]
|
@@ -3,13 +3,17 @@ require 'spec_helper'
|
|
3
3
|
module RubySpeech
|
4
4
|
module GRXML
|
5
5
|
describe Grammar do
|
6
|
+
let(:doc) { Nokogiri::XML::Document.new }
|
7
|
+
|
8
|
+
subject { described_class.new doc }
|
9
|
+
|
6
10
|
it { should be_a_valid_grxml_document }
|
7
11
|
|
8
12
|
its(:name) { should == 'grammar' }
|
9
13
|
its(:language) { should == 'en-US' }
|
10
14
|
|
11
15
|
describe "setting options in initializers" do
|
12
|
-
subject { Grammar.new :language => 'jp', :base_uri => 'blah', :root => "main_rule", :tag_format => "semantics/1.0" }
|
16
|
+
subject { Grammar.new doc, :language => 'jp', :base_uri => 'blah', :root => "main_rule", :tag_format => "semantics/1.0" }
|
13
17
|
|
14
18
|
its(:language) { should == 'jp' }
|
15
19
|
its(:base_uri) { should == 'blah' }
|
@@ -18,14 +22,14 @@ module RubySpeech
|
|
18
22
|
end
|
19
23
|
|
20
24
|
describe "setting dtmf mode" do
|
21
|
-
subject { Grammar.new :mode => 'dtmf' }
|
25
|
+
subject { Grammar.new doc, :mode => 'dtmf' }
|
22
26
|
its(:mode) { should == :dtmf }
|
23
27
|
its(:dtmf?) { should be true }
|
24
28
|
its(:voice?) { should be false }
|
25
29
|
end
|
26
30
|
|
27
31
|
describe "setting voice mode" do
|
28
|
-
subject { Grammar.new :mode => 'voice' }
|
32
|
+
subject { Grammar.new doc, :mode => 'voice' }
|
29
33
|
its(:mode) { should == :voice }
|
30
34
|
its(:voice?) { should be true }
|
31
35
|
its(:dtmf?) { should be false }
|
@@ -66,33 +70,33 @@ module RubySpeech
|
|
66
70
|
|
67
71
|
describe "comparing objects" do
|
68
72
|
it "should be equal if the content, language and base uri are the same" do
|
69
|
-
Grammar.new(:language => 'en-GB', :base_uri => 'blah', :content => "Hello there").should == Grammar.new(:language => 'en-GB', :base_uri => 'blah', :content => "Hello there")
|
73
|
+
Grammar.new(doc, :language => 'en-GB', :base_uri => 'blah', :content => "Hello there").should == Grammar.new(doc, :language => 'en-GB', :base_uri => 'blah', :content => "Hello there")
|
70
74
|
end
|
71
75
|
|
72
76
|
describe "when the content is different" do
|
73
77
|
it "should not be equal" do
|
74
|
-
Grammar.new(:content => "Hello").should_not == Grammar.new(:content => "Hello there")
|
78
|
+
Grammar.new(doc, :content => "Hello").should_not == Grammar.new(doc, :content => "Hello there")
|
75
79
|
end
|
76
80
|
end
|
77
81
|
|
78
82
|
describe "when the language is different" do
|
79
83
|
it "should not be equal" do
|
80
|
-
Grammar.new(:language => 'en-US').should_not == Grammar.new(:language => 'en-GB')
|
84
|
+
Grammar.new(doc, :language => 'en-US').should_not == Grammar.new(doc, :language => 'en-GB')
|
81
85
|
end
|
82
86
|
end
|
83
87
|
|
84
88
|
describe "when the base URI is different" do
|
85
89
|
it "should not be equal" do
|
86
|
-
Grammar.new(:base_uri => 'foo').should_not == Grammar.new(:base_uri => 'bar')
|
90
|
+
Grammar.new(doc, :base_uri => 'foo').should_not == Grammar.new(doc, :base_uri => 'bar')
|
87
91
|
end
|
88
92
|
end
|
89
93
|
|
90
94
|
describe "when the children are different" do
|
91
95
|
it "should not be equal" do
|
92
|
-
g1 = Grammar.new
|
93
|
-
g1 << Rule.new(:id => 'main1')
|
94
|
-
g2 = Grammar.new
|
95
|
-
g2 << Rule.new(:id => 'main2')
|
96
|
+
g1 = Grammar.new doc
|
97
|
+
g1 << Rule.new(doc, :id => 'main1')
|
98
|
+
g2 = Grammar.new doc
|
99
|
+
g2 << Rule.new(doc, :id => 'main2')
|
96
100
|
|
97
101
|
g1.should_not == g2
|
98
102
|
end
|
@@ -100,20 +104,20 @@ module RubySpeech
|
|
100
104
|
end
|
101
105
|
|
102
106
|
it "should allow creating child GRXML elements" do
|
103
|
-
g = Grammar.new
|
104
|
-
g.
|
105
|
-
expected_g = Grammar.new
|
106
|
-
expected_g << Rule.new(:id => :main, :scope => 'public')
|
107
|
+
g = Grammar.new doc
|
108
|
+
g.rule :id => :main, :scope => 'public'
|
109
|
+
expected_g = Grammar.new doc
|
110
|
+
expected_g << Rule.new(doc, :id => :main, :scope => 'public')
|
107
111
|
g.should == expected_g
|
108
112
|
end
|
109
113
|
|
110
114
|
describe "<<" do
|
111
115
|
it "should accept Rule" do
|
112
|
-
lambda { subject << Rule.new }.should_not raise_error
|
116
|
+
lambda { subject << Rule.new(doc) }.should_not raise_error
|
113
117
|
end
|
114
118
|
|
115
119
|
it "should accept Tag" do
|
116
|
-
lambda { subject << Tag.new }.should_not raise_error
|
120
|
+
lambda { subject << Tag.new(doc) }.should_not raise_error
|
117
121
|
end
|
118
122
|
|
119
123
|
it "should raise InvalidChildError with non-acceptable objects" do
|
@@ -135,26 +139,27 @@ module RubySpeech
|
|
135
139
|
|
136
140
|
describe "concat" do
|
137
141
|
it "should allow concatenation" do
|
138
|
-
grammar1 = Grammar.new
|
139
|
-
grammar1 << Rule.new(:id => 'frank', :scope => 'public', :content => "Hi Frank")
|
140
|
-
grammar2 = Grammar.new
|
141
|
-
grammar2 << Rule.new(:id => 'millie', :scope => 'public', :content => "Hi Millie")
|
142
|
+
grammar1 = Grammar.new doc
|
143
|
+
grammar1 << Rule.new(doc, :id => 'frank', :scope => 'public', :content => "Hi Frank")
|
144
|
+
grammar2 = Grammar.new doc
|
145
|
+
grammar2 << Rule.new(doc, :id => 'millie', :scope => 'public', :content => "Hi Millie")
|
142
146
|
|
143
|
-
expected_concat = Grammar.new
|
144
|
-
expected_concat << Rule.new(:id => 'frank', :scope => 'public', :content => "Hi Frank")
|
145
|
-
expected_concat << Rule.new(:id => 'millie', :scope => 'public', :content => "Hi Millie")
|
147
|
+
expected_concat = Grammar.new doc
|
148
|
+
expected_concat << Rule.new(doc, :id => 'frank', :scope => 'public', :content => "Hi Frank")
|
149
|
+
expected_concat << Rule.new(doc, :id => 'millie', :scope => 'public', :content => "Hi Millie")
|
146
150
|
|
147
151
|
concat = grammar1 + grammar2
|
148
152
|
concat.should == expected_concat
|
153
|
+
concat.document.root.should == concat
|
149
154
|
concat.to_s.should_not include('default')
|
150
155
|
end
|
151
156
|
end
|
152
157
|
|
153
158
|
it "should allow finding its root rule" do
|
154
|
-
grammar = GRXML::Grammar.new :root => 'foo'
|
155
|
-
bar = GRXML::Rule.new :id => 'bar'
|
159
|
+
grammar = GRXML::Grammar.new doc, :root => 'foo'
|
160
|
+
bar = GRXML::Rule.new doc, :id => 'bar'
|
156
161
|
grammar << bar
|
157
|
-
foo = GRXML::Rule.new :id => 'foo'
|
162
|
+
foo = GRXML::Rule.new doc, :id => 'foo'
|
158
163
|
grammar << foo
|
159
164
|
|
160
165
|
grammar.root_rule.should == foo
|
@@ -229,7 +234,7 @@ module RubySpeech
|
|
229
234
|
|
230
235
|
let(:tokenized_version) do
|
231
236
|
expected_tokens = Array(tokens).map do |s|
|
232
|
-
Token.new.tap { |t| t << s }
|
237
|
+
Token.new(doc).tap { |t| t << s }
|
233
238
|
end
|
234
239
|
single_rule_grammar expected_tokens
|
235
240
|
end
|
@@ -291,7 +296,7 @@ module RubySpeech
|
|
291
296
|
end
|
292
297
|
|
293
298
|
context "with a single XML token" do
|
294
|
-
let(:content) { [Token.new.tap { |t| t << 'San Francisco' }] }
|
299
|
+
let(:content) { [Token.new(doc).tap { |t| t << 'San Francisco' }] }
|
295
300
|
let(:tokens) { ['San Francisco'] }
|
296
301
|
|
297
302
|
it "should tokenize correctly" do
|
@@ -303,7 +308,7 @@ module RubySpeech
|
|
303
308
|
let(:content) do
|
304
309
|
[
|
305
310
|
'Welcome to "San Francisco"',
|
306
|
-
Token.new.tap { |t| t << 'Have Fun!' }
|
311
|
+
Token.new(doc).tap { |t| t << 'Have Fun!' }
|
307
312
|
]
|
308
313
|
end
|
309
314
|
|
@@ -3,7 +3,9 @@ require 'spec_helper'
|
|
3
3
|
module RubySpeech
|
4
4
|
module GRXML
|
5
5
|
describe Item do
|
6
|
-
|
6
|
+
let(:doc) { Nokogiri::XML::Document.new }
|
7
|
+
|
8
|
+
subject { Item.new doc, :weight => 1.1, :repeat => '1' }
|
7
9
|
|
8
10
|
its(:name) { should == 'item' }
|
9
11
|
|
@@ -168,23 +170,23 @@ module RubySpeech
|
|
168
170
|
end
|
169
171
|
|
170
172
|
it "should accept OneOf" do
|
171
|
-
lambda { subject << OneOf.new }.should_not raise_error
|
173
|
+
lambda { subject << OneOf.new(doc) }.should_not raise_error
|
172
174
|
end
|
173
175
|
|
174
176
|
it "should accept Item" do
|
175
|
-
lambda { subject << Item.new }.should_not raise_error
|
177
|
+
lambda { subject << Item.new(doc) }.should_not raise_error
|
176
178
|
end
|
177
179
|
|
178
180
|
it "should accept Ruleref" do
|
179
|
-
lambda { subject << Ruleref.new }.should_not raise_error
|
181
|
+
lambda { subject << Ruleref.new(doc) }.should_not raise_error
|
180
182
|
end
|
181
183
|
|
182
184
|
it "should accept Tag" do
|
183
|
-
lambda { subject << Tag.new }.should_not raise_error
|
185
|
+
lambda { subject << Tag.new(doc) }.should_not raise_error
|
184
186
|
end
|
185
187
|
|
186
188
|
it "should accept Token" do
|
187
|
-
lambda { subject << Token.new }.should_not raise_error
|
189
|
+
lambda { subject << Token.new(doc) }.should_not raise_error
|
188
190
|
end
|
189
191
|
end
|
190
192
|
end # Item
|
@@ -3,6 +3,10 @@ require 'spec_helper'
|
|
3
3
|
module RubySpeech
|
4
4
|
module GRXML
|
5
5
|
describe OneOf do
|
6
|
+
let(:doc) { Nokogiri::XML::Document.new }
|
7
|
+
|
8
|
+
subject { described_class.new doc }
|
9
|
+
|
6
10
|
its(:name) { should == 'one-of' }
|
7
11
|
|
8
12
|
it 'registers itself' do
|
@@ -25,7 +29,7 @@ module RubySpeech
|
|
25
29
|
|
26
30
|
describe "<<" do
|
27
31
|
it "should accept Item" do
|
28
|
-
lambda { subject << Item.new }.should_not raise_error
|
32
|
+
lambda { subject << Item.new(doc) }.should_not raise_error
|
29
33
|
end
|
30
34
|
|
31
35
|
it "should raise InvalidChildError with non-acceptable objects" do
|
@@ -35,12 +39,12 @@ module RubySpeech
|
|
35
39
|
|
36
40
|
describe "comparing objects" do
|
37
41
|
it "should be equal if the language (when specified) is the same" do
|
38
|
-
OneOf.new(:language => "jp").should == OneOf.new(:language => "jp")
|
42
|
+
OneOf.new(doc, :language => "jp").should == OneOf.new(doc, :language => "jp")
|
39
43
|
end
|
40
44
|
|
41
45
|
describe "when the language is different" do
|
42
46
|
it "should not be equal" do
|
43
|
-
OneOf.new(:language => "jp").should_not == OneOf.new(:content => "fr-CA")
|
47
|
+
OneOf.new(doc, :language => "jp").should_not == OneOf.new(doc, :content => "fr-CA")
|
44
48
|
end
|
45
49
|
end
|
46
50
|
end
|
@@ -3,7 +3,9 @@ require 'spec_helper'
|
|
3
3
|
module RubySpeech
|
4
4
|
module GRXML
|
5
5
|
describe Rule do
|
6
|
-
|
6
|
+
let(:doc) { Nokogiri::XML::Document.new }
|
7
|
+
|
8
|
+
subject { Rule.new doc, :id => 'one', :scope => 'public' }
|
7
9
|
|
8
10
|
its(:name) { should == 'rule' }
|
9
11
|
|
@@ -63,30 +65,30 @@ module RubySpeech
|
|
63
65
|
|
64
66
|
describe "comparing objects" do
|
65
67
|
it "should be equal if the content, language, id, and scope are the same" do
|
66
|
-
Rule.new(:language => 'jp', :id => :main, :scope => :public, :content => "hello").should == Rule.new(:language => 'jp', :id => :main, :scope => :public, :content => "hello")
|
68
|
+
Rule.new(doc, :language => 'jp', :id => :main, :scope => :public, :content => "hello").should == Rule.new(doc, :language => 'jp', :id => :main, :scope => :public, :content => "hello")
|
67
69
|
end
|
68
70
|
|
69
71
|
describe "when the content is different" do
|
70
72
|
it "should not be equal" do
|
71
|
-
Rule.new(:content => "Hello").should_not == Rule.new(:content => "Hello there")
|
73
|
+
Rule.new(doc, :content => "Hello").should_not == Rule.new(doc, :content => "Hello there")
|
72
74
|
end
|
73
75
|
end
|
74
76
|
|
75
77
|
describe "when the language is different" do
|
76
78
|
it "should not be equal" do
|
77
|
-
Rule.new(:language => "jp").should_not == Rule.new(:language => "esperanto")
|
79
|
+
Rule.new(doc, :language => "jp").should_not == Rule.new(doc, :language => "esperanto")
|
78
80
|
end
|
79
81
|
end
|
80
82
|
|
81
83
|
describe "when the id is different" do
|
82
84
|
it "should not be equal" do
|
83
|
-
Rule.new(:id => :main).should_not == Rule.new(:id => :dtmf)
|
85
|
+
Rule.new(doc, :id => :main).should_not == Rule.new(doc, :id => :dtmf)
|
84
86
|
end
|
85
87
|
end
|
86
88
|
|
87
89
|
describe "when the scope is different" do
|
88
90
|
it "should not be equal" do
|
89
|
-
Rule.new(:scope => :public).should_not == Rule.new(:scope => :private)
|
91
|
+
Rule.new(doc, :scope => :public).should_not == Rule.new(doc, :scope => :private)
|
90
92
|
end
|
91
93
|
end
|
92
94
|
end
|
@@ -97,28 +99,28 @@ module RubySpeech
|
|
97
99
|
end
|
98
100
|
|
99
101
|
it "should accept OneOf" do
|
100
|
-
lambda { subject << OneOf.new }.should_not raise_error
|
102
|
+
lambda { subject << OneOf.new(doc) }.should_not raise_error
|
101
103
|
end
|
102
104
|
|
103
105
|
it "should accept Item" do
|
104
|
-
lambda { subject << Item.new }.should_not raise_error
|
106
|
+
lambda { subject << Item.new(doc) }.should_not raise_error
|
105
107
|
end
|
106
108
|
|
107
109
|
it "should accept Ruleref" do
|
108
|
-
lambda { subject << Ruleref.new }.should_not raise_error
|
110
|
+
lambda { subject << Ruleref.new(doc) }.should_not raise_error
|
109
111
|
end
|
110
112
|
|
111
113
|
it "should accept Tag" do
|
112
|
-
lambda { subject << Tag.new }.should_not raise_error
|
114
|
+
lambda { subject << Tag.new(doc) }.should_not raise_error
|
113
115
|
end
|
114
116
|
|
115
117
|
it "should accept Token" do
|
116
|
-
lambda { subject << Token.new }.should_not raise_error
|
118
|
+
lambda { subject << Token.new(doc) }.should_not raise_error
|
117
119
|
end
|
118
120
|
end
|
119
121
|
|
120
122
|
it "should raise ArgumentError with any other scope" do
|
121
|
-
lambda { Rule.new :id => 'one', :scope => 'invalid_scope' }.should raise_error(ArgumentError, "A Rule's scope can only be 'public' or 'private'")
|
123
|
+
lambda { Rule.new doc, :id => 'one', :scope => 'invalid_scope' }.should raise_error(ArgumentError, "A Rule's scope can only be 'public' or 'private'")
|
122
124
|
end
|
123
125
|
end # Rule
|
124
126
|
end # GRXML
|
@@ -3,7 +3,9 @@ require 'spec_helper'
|
|
3
3
|
module RubySpeech
|
4
4
|
module GRXML
|
5
5
|
describe Ruleref do
|
6
|
-
|
6
|
+
let(:doc) { Nokogiri::XML::Document.new }
|
7
|
+
|
8
|
+
subject { Ruleref.new doc, :uri => '#testrule' }
|
7
9
|
|
8
10
|
its(:name) { should == 'ruleref' }
|
9
11
|
its(:uri) { should == '#testrule' }
|
@@ -23,7 +25,7 @@ module RubySpeech
|
|
23
25
|
end
|
24
26
|
|
25
27
|
describe "#special" do
|
26
|
-
subject { Ruleref.new }
|
28
|
+
subject { Ruleref.new doc }
|
27
29
|
|
28
30
|
context "with reserved values" do
|
29
31
|
it "with a valid value" do
|
@@ -47,7 +49,7 @@ module RubySpeech
|
|
47
49
|
|
48
50
|
describe "only uri or special can be specified" do
|
49
51
|
it "should raise an error" do
|
50
|
-
lambda { subject << Ruleref.new(:uri => '#test', :special => :NULL) }.should raise_error(ArgumentError, "A Ruleref can only take uri or special")
|
52
|
+
lambda { subject << Ruleref.new(doc, :uri => '#test', :special => :NULL) }.should raise_error(ArgumentError, "A Ruleref can only take uri or special")
|
51
53
|
end
|
52
54
|
end
|
53
55
|
end # Ruleref
|