Skip to content

Commit 15aa2cf

Browse files
committed
find quit words with word bounds
1 parent a3002b4 commit 15aa2cf

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/eliza/sentence.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def initialize(text)
77
end
88

99
def quit?
10-
data.quit_words.find{|quit_word| text.include? quit_word }
10+
data.quit_words.find{|quit_word| text[/\b#{quit_word}\b/] }
1111
end
1212

1313
def transform

spec/eliza/sentence_spec.rb

+5
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,10 @@
6565
let(:text) { 'Bye! its been good talking to you.' }
6666
it { should match /Goodbye/ }
6767
end
68+
69+
context 'when the quit word is part of another word' do
70+
let(:text) { 'I liked rockabye baby' }
71+
it { should_not match /Goodbye/ }
72+
end
6873
end
6974
end

0 commit comments

Comments
 (0)