Permalink
Browse files

Handle NLSML documents with just the NLSML namespace

  • Loading branch information...
1 parent 1fbd7cf commit f409567c6a846cee63b318593a3fff72cf34c6ad @benlangfeld committed Nov 22, 2012
Showing with 40 additions and 1 deletion.
  1. +1 −0 lib/ruby_speech/nlsml/document.rb
  2. +39 −1 spec/ruby_speech/nlsml_spec.rb
View
1 lib/ruby_speech/nlsml/document.rb
@@ -42,6 +42,7 @@ def input_hash_for_interpretation(interpretation)
def instance_hash_for_interpretation(interpretation)
instance_element = interpretation.at_xpath 'xf:instance', 'xf' => XFORMS_NAMESPACE
+ instance_element ||= interpretation.at_xpath 'ns:instance', 'ns' => NLSML_NAMESPACE
instance_element ||= interpretation.at_xpath 'instance'
return unless instance_element
element_children_key_value instance_element
View
40 spec/ruby_speech/nlsml_spec.rb
@@ -202,7 +202,7 @@
its(:best_interpretation) { should == expected_best_interpretation }
end
- context "with no namespaces (because some vendors think this is ok" do
+ context "with no namespaces (because some vendors think this is ok)" do
let :example_document do
'''
<result grammar="http://flight">
@@ -239,5 +239,43 @@
its(:interpretations) { should == expected_interpretations }
its(:best_interpretation) { should == expected_best_interpretation }
end
+
+ context "with just an NLSML namespace (because we need something, damnit!)" do
+ let :example_document do
+ '''
+<result xmlns="http://www.w3c.org/2000/11/nlsml" grammar="http://flight">
+ <interpretation confidence="60">
+ <input mode="speech">I want to go to Pittsburgh</input>
+ <model>
+ <group name="airline">
+ <string name="to_city"/>
+ </group>
+ </model>
+ <instance>
+ <airline>
+ <to_city>Pittsburgh</to_city>
+ </airline>
+ </instance>
+ </interpretation>
+ <interpretation confidence="40">
+ <input>I want to go to Stockholm</input>
+ <model>
+ <group name="airline">
+ <string name="to_city"/>
+ </group>
+ </model>
+ <instance>
+ <airline>
+ <to_city>Stockholm</to_city>
+ </airline>
+ </instance>
+ </interpretation>
+</result>
+ '''
+ end
+
+ its(:interpretations) { should == expected_interpretations }
+ its(:best_interpretation) { should == expected_best_interpretation }
+ end
end
end

0 comments on commit f409567

Please sign in to comment.