ruby_speech 2.1.1 → 2.1.2
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/ruby_speech/nlsml/document.rb +10 -13
- data/lib/ruby_speech/version.rb +1 -1
- data/spec/ruby_speech/nlsml_spec.rb +35 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: caf6dc66fd5b216e0825c25c2df9c16324e955e1
|
4
|
+
data.tar.gz: ecd61a61b6a362521b6915d7eac46b47556f55c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a08ac02e15a99aaf0f4ec753cb22fbf63304d4d42df34215dffe15255d344cf2d06bc23ab448f2152069e1c074d3d47b9a4978a4e04a1a746124a5658ce8a1e
|
7
|
+
data.tar.gz: 4a96f1f2fb4a56a08f6328bd6caa89ec4b47ee8638ee1c0d2e7bd3e2a867274b1d19d43039b423144e7e195140380e474c1533109e5ca0d165fc919e3b63fc69
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# [develop](https://github.com/benlangfeld/ruby_speech)
|
2
2
|
|
3
|
+
# [2.1.2](https://github.com/benlangfeld/ruby_speech/compare/v2.1.1...v2.1.2) - [2013-06-05](https://rubygems.org/gems/ruby_speech/versions/2.1.2)
|
4
|
+
* Bugfix: Allow wrapping a pre-parsed XML node nested arbitrary deeply as an NLSML document
|
5
|
+
|
3
6
|
# [2.1.1](https://github.com/benlangfeld/ruby_speech/compare/v2.1.0...v2.1.1) - [2013-05-09](https://rubygems.org/gems/ruby_speech/versions/2.1.1)
|
4
7
|
* Bugfix: Support numeric SISR literal tags
|
5
8
|
|
@@ -4,15 +4,16 @@ module RubySpeech
|
|
4
4
|
module NLSML
|
5
5
|
class Document < SimpleDelegator
|
6
6
|
def initialize(xml)
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
result = xml.respond_to?(:root) ? xml.root : xml
|
8
|
+
unless result.namespace
|
9
|
+
result.default_namespace = NLSML_NAMESPACE
|
10
|
+
result = Nokogiri::XML.parse(xml.to_xml, nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS).root
|
10
11
|
end
|
11
|
-
super
|
12
|
+
super result
|
12
13
|
end
|
13
14
|
|
14
15
|
def grammar
|
15
|
-
|
16
|
+
self['grammar']
|
16
17
|
end
|
17
18
|
|
18
19
|
def interpretations
|
@@ -44,15 +45,15 @@ module RubySpeech
|
|
44
45
|
end
|
45
46
|
|
46
47
|
def nomatch_elements
|
47
|
-
|
48
|
+
xpath 'ns:interpretation/ns:input/ns:nomatch', 'ns' => NLSML_NAMESPACE
|
48
49
|
end
|
49
50
|
|
50
51
|
def noinput_elements
|
51
|
-
|
52
|
+
xpath 'ns:interpretation/ns:input/ns:noinput', 'ns' => NLSML_NAMESPACE
|
52
53
|
end
|
53
54
|
|
54
55
|
def input_elements
|
55
|
-
|
56
|
+
xpath 'ns:interpretation/ns:input', 'ns' => NLSML_NAMESPACE
|
56
57
|
end
|
57
58
|
|
58
59
|
def input_hash_for_interpretation(interpretation)
|
@@ -107,12 +108,8 @@ module RubySpeech
|
|
107
108
|
}
|
108
109
|
end
|
109
110
|
|
110
|
-
def result
|
111
|
-
root
|
112
|
-
end
|
113
|
-
|
114
111
|
def interpretation_nodes
|
115
|
-
nodes =
|
112
|
+
nodes = xpath 'ns:interpretation', 'ns' => NLSML_NAMESPACE
|
116
113
|
nodes.sort_by { |int| -int[:confidence].to_f }
|
117
114
|
end
|
118
115
|
end
|
data/lib/ruby_speech/version.rb
CHANGED
@@ -124,6 +124,41 @@ describe RubySpeech::NLSML do
|
|
124
124
|
subject.should_not be == RubySpeech.parse(empty_result)
|
125
125
|
end
|
126
126
|
|
127
|
+
context "when the XML is already parsed and is not the root of a document" do
|
128
|
+
let :example_document do
|
129
|
+
'''
|
130
|
+
<foo>
|
131
|
+
<result xmlns="http://www.ietf.org/xml/ns/mrcpv2" grammar="http://flight">
|
132
|
+
<interpretation confidence="0.6">
|
133
|
+
<input mode="speech">I want to go to Pittsburgh</input>
|
134
|
+
<instance>
|
135
|
+
<airline>
|
136
|
+
<to_city>Pittsburgh</to_city>
|
137
|
+
</airline>
|
138
|
+
</instance>
|
139
|
+
</interpretation>
|
140
|
+
<interpretation confidence="0.4">
|
141
|
+
<input>I want to go to Stockholm</input>
|
142
|
+
<instance>
|
143
|
+
<airline>
|
144
|
+
<to_city>Stockholm</to_city>
|
145
|
+
</airline>
|
146
|
+
</instance>
|
147
|
+
</interpretation>
|
148
|
+
</result>
|
149
|
+
</foo>
|
150
|
+
'''
|
151
|
+
end
|
152
|
+
|
153
|
+
let(:node) { Nokogiri::XML(example_document).at_xpath('//mrcp:result', mrcp: "http://www.ietf.org/xml/ns/mrcpv2") }
|
154
|
+
|
155
|
+
subject do
|
156
|
+
RubySpeech::NLSML::Document.new node
|
157
|
+
end
|
158
|
+
|
159
|
+
its(:grammar) { should == 'http://flight' }
|
160
|
+
end
|
161
|
+
|
127
162
|
context "with an interpretation that has no instance" do
|
128
163
|
let :example_document do
|
129
164
|
'''
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_speech
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Langfeld
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05
|
11
|
+
date: 2013-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: niceogiri
|
@@ -319,7 +319,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
319
319
|
version: '0'
|
320
320
|
requirements: []
|
321
321
|
rubyforge_project: ruby_speech
|
322
|
-
rubygems_version: 2.0.
|
322
|
+
rubygems_version: 2.0.3
|
323
323
|
signing_key:
|
324
324
|
specification_version: 4
|
325
325
|
summary: A Ruby library for TTS & ASR document preparation
|