ruby_speech 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/ruby_speech/grxml/element.rb +1 -1
- data/lib/ruby_speech/grxml/grammar.rb +2 -1
- data/lib/ruby_speech/grxml/matcher.rb +13 -6
- data/lib/ruby_speech/grxml/tag.rb +4 -0
- data/lib/ruby_speech/version.rb +1 -1
- data/spec/ruby_speech/grxml/matcher_spec.rb +35 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 412147ee2efc1f9e8db108476c6939cc8723a68b
|
4
|
+
data.tar.gz: c73dbaad254dd7e90d1f08520a147bb9ebcbe20a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a4be1f240f91097e810e8394619c6efd9a7b4e2bf0ef817d0af65f313fcfe19d992c5e1d1ca29a06b355fd931fc8c70d4febe58221499a531c440c17b24b6eb
|
7
|
+
data.tar.gz: f734ad2b4103ed7c21a9d15e0abe7141a4ed4edcc1ba8b6c830e4fc37254fc466c1c95cd61c15dc6002437ea6a83abb2dbe95fef8ee012cb404154de0437099a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# [develop](https://github.com/benlangfeld/ruby_speech)
|
2
2
|
|
3
|
+
# [2.1.0](https://github.com/benlangfeld/ruby_speech/compare/v2.0.2...v2.1.0) - [2013-05-07](https://rubygems.org/gems/ruby_speech/versions/2.1.0)
|
4
|
+
* Feature: Support for SISR literal syntax
|
5
|
+
|
3
6
|
# [2.0.2](https://github.com/benlangfeld/ruby_speech/compare/v2.0.1...v2.0.2) - [2013-05-01](https://rubygems.org/gems/ruby_speech/versions/2.0.2)
|
4
7
|
* Bugfix: Differentiate between GRXML match cases with are and are not maximal
|
5
8
|
* A Match can accept further input while still matching, while a a MaxMatch cannot.
|
@@ -123,7 +123,8 @@ module RubySpeech
|
|
123
123
|
traverse do |element|
|
124
124
|
next unless element.is_a? Nokogiri::XML::Text
|
125
125
|
|
126
|
-
|
126
|
+
element_type = self.class.import(element.parent).class
|
127
|
+
next if [Token, Tag].include?(element_type)
|
127
128
|
|
128
129
|
tokens = split_tokens(element).map do |string|
|
129
130
|
Token.new.tap { |token| token << string }
|
@@ -8,6 +8,10 @@ end
|
|
8
8
|
module RubySpeech
|
9
9
|
module GRXML
|
10
10
|
class Matcher
|
11
|
+
UTTERANCE_CONVERTER = Hash.new { |hash, key| hash[key] = key }
|
12
|
+
UTTERANCE_CONVERTER['*'] = 'star'
|
13
|
+
UTTERANCE_CONVERTER['#'] = 'pound'
|
14
|
+
|
11
15
|
attr_reader :grammar
|
12
16
|
|
13
17
|
def initialize(grammar)
|
@@ -106,13 +110,16 @@ module RubySpeech
|
|
106
110
|
end
|
107
111
|
|
108
112
|
def interpret_utterance(utterance)
|
109
|
-
|
110
|
-
|
111
|
-
|
113
|
+
find_tag(utterance) || utterance.chars.inject([]) do |array, digit|
|
114
|
+
array << "dtmf-#{UTTERANCE_CONVERTER[digit]}"
|
115
|
+
end.join(' ')
|
116
|
+
end
|
112
117
|
|
113
|
-
|
114
|
-
|
115
|
-
|
118
|
+
def find_tag(utterance)
|
119
|
+
match = /#{regexp_content}/.match(utterance)
|
120
|
+
return if match.captures.all?(&:nil?)
|
121
|
+
last_capture_index = match.captures.size - 1 - match.captures.reverse.find_index { |item| !item.nil? }
|
122
|
+
match.names[last_capture_index]
|
116
123
|
end
|
117
124
|
end
|
118
125
|
end
|
@@ -20,6 +20,10 @@ module RubySpeech
|
|
20
20
|
raise InvalidChildError, "A Tag can only accept Strings as children" unless VALID_CHILD_TYPES.include? arg.class
|
21
21
|
super
|
22
22
|
end
|
23
|
+
|
24
|
+
def regexp_content # :nodoc:
|
25
|
+
"?<#{content}>"
|
26
|
+
end
|
23
27
|
end # Tag
|
24
28
|
end # GRXML
|
25
29
|
end # RubySpeech
|
data/lib/ruby_speech/version.rb
CHANGED
@@ -34,6 +34,41 @@ module RubySpeech
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
context "with a grammar with SISR tags" do
|
38
|
+
let :grammar do
|
39
|
+
RubySpeech::GRXML.draw mode: 'dtmf', root: 'options', tag_format: 'semantics/1.0-literals' do
|
40
|
+
rule id: 'options', scope: 'public' do
|
41
|
+
item do
|
42
|
+
one_of do
|
43
|
+
item do
|
44
|
+
tag { 'foo' }
|
45
|
+
'1'
|
46
|
+
end
|
47
|
+
item do
|
48
|
+
tag { 'bar' }
|
49
|
+
'2'
|
50
|
+
end
|
51
|
+
item do
|
52
|
+
tag { 'baz' }
|
53
|
+
'3'
|
54
|
+
end
|
55
|
+
item do
|
56
|
+
tag { 'lala' }
|
57
|
+
'4'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should return the literal tag interpretation" do
|
66
|
+
expected_match = GRXML::MaxMatch.new mode: :dtmf, confidence: 1,
|
67
|
+
utterance: '2', interpretation: 'bar'
|
68
|
+
subject.match('2').should == expected_match
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
37
72
|
context "with a grammar that takes two specific digits" do
|
38
73
|
let(:grammar) do
|
39
74
|
GRXML.draw :mode => :dtmf, :root => 'digits' do
|
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.0
|
4
|
+
version: 2.1.0
|
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-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: niceogiri
|