-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Basic matching to a grammar
- Loading branch information
1 parent
d7f063a
commit aee1b77
Showing
10 changed files
with
317 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module RubySpeech | ||
module GRXML | ||
class Match | ||
attr_accessor :mode, :confidence, :utterance, :interpretation | ||
|
||
def initialize(options = {}) | ||
options.each_pair { |k, v| self.send :"#{k}=", v } | ||
end | ||
|
||
def eql?(o) | ||
o.is_a?(self.class) && [:mode, :confidence, :utterance, :interpretation].all? { |f| self.__send__(f) == o.__send__(f) } | ||
end | ||
alias :== :eql? | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module RubySpeech | ||
module GRXML | ||
class NoMatch | ||
def eql?(o) | ||
o.is_a? self.class | ||
end | ||
alias :== :eql? | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
require 'spec_helper' | ||
|
||
module RubySpeech | ||
module GRXML | ||
describe Match do | ||
subject do | ||
Match.new :mode => :dtmf, | ||
:confidence => 1, | ||
:utterance => '6', | ||
:interpretation => 'foo' | ||
end | ||
|
||
its(:mode) { should == :dtmf } | ||
its(:confidence) { should == 1 } | ||
its(:utterance) { should == '6' } | ||
its(:interpretation) { should == 'foo' } | ||
|
||
describe "equality" do | ||
it "should be equal when mode, confidence, utterance and interpretation are the same" do | ||
Match.new(:mode => :dtmf, :confidence => 1, :utterance => '6', :interpretation => 'foo').should == Match.new(:mode => :dtmf, :confidence => 1, :utterance => '6', :interpretation => 'foo') | ||
end | ||
|
||
describe "when the mode is different" do | ||
it "should not be equal" do | ||
Match.new(:mode => :dtmf).should_not == Match.new(:mode => :speech) | ||
end | ||
end | ||
|
||
describe "when the confidence is different" do | ||
it "should not be equal" do | ||
Match.new(:confidence => 1).should_not == Match.new(:confidence => 0) | ||
end | ||
end | ||
|
||
describe "when the utterance is different" do | ||
it "should not be equal" do | ||
Match.new(:utterance => '6').should_not == Match.new(:utterance => 'foo') | ||
end | ||
end | ||
|
||
describe "when the interpretation is different" do | ||
it "should not be equal" do | ||
Match.new(:interpretation => 'foo').should_not == Match.new(:interpretation => 'bar') | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'spec_helper' | ||
|
||
module RubySpeech | ||
module GRXML | ||
describe NoMatch do | ||
describe "equality" do | ||
it "should be equal to another NoMatch" do | ||
NoMatch.new.should == NoMatch.new | ||
end | ||
|
||
it "should not equal a match" do | ||
NoMatch.new.should_not == Match.new | ||
end | ||
end | ||
end | ||
end | ||
end |