TYING IT TOGETHER: DEVELOPING A LARGER RUBY APPLICATION in Font

Encoder Data Matrix in Font TYING IT TOGETHER: DEVELOPING A LARGER RUBY APPLICATION

CHAPTER 12 TYING IT TOGETHER: DEVELOPING A LARGER RUBY APPLICATION
Data Matrix Generation In None
Using Barcode generator for Font Control to generate, create Data Matrix ECC200 image in Font applications.
www.OnBarcode.com
UPC Symbol Generation In None
Using Barcode maker for Font Control to generate, create Universal Product Code version A image in Font applications.
www.OnBarcode.com
Therefore, if the chosen response contains an asterisk (the character you re using as a placeholder in response phrases), you ll need to substitute in the relevant part of the original sentence into the phrase and perform pronoun switching on that part. Here s the new version of possible_responses with the changes in bold:
EAN128 Creator In None
Using Barcode drawer for Font Control to generate, create GS1 128 image in Font applications.
www.OnBarcode.com
Generate European Article Number 13 In None
Using Barcode generation for Font Control to generate, create EAN-13 Supplement 5 image in Font applications.
www.OnBarcode.com
def possible_responses(sentence) responses = [] # Find all patterns to try to match against @data[:responses].keys.each do |pattern| next unless pattern.is_a (String) # For each pattern, see if the supplied sentence contains # a match. Remove substitution symbols (*) before checking. # Push all responses to the responses array. if sentence.match('\b' + pattern.gsub(/\*/, '') + '\b') # If the pattern contains substitution placeholders, # perform the substitutions if pattern.include ('*') responses << @data[:responses][pattern].collect do |phrase| # First, erase everything before the placeholder # leaving everything after it matching_section = sentence.sub(/^.*#{pattern}\s+/, '') # Then substitute the text after the placeholder, with # the pronouns switched phrase.sub('*', WordPlay.switch_pronouns(matching_section)) end else # No placeholders Just add the phrases to the array responses << @data[:responses][pattern] end end end # If there were no matches, add the default ones responses << @data[:responses][:default] if responses.empty # Flatten the blocks of responses to a flat array responses.flatten end
Making Barcode In None
Using Barcode creator for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
DataMatrix Drawer In None
Using Barcode creation for Font Control to generate, create Data Matrix ECC200 image in Font applications.
www.OnBarcode.com
CHAPTER 12 TYING IT TOGETHER: DEVELOPING A LARGER RUBY APPLICATION
Draw Code39 In None
Using Barcode creation for Font Control to generate, create ANSI/AIM Code 39 image in Font applications.
www.OnBarcode.com
Make ISSN - 13 In None
Using Barcode generation for Font Control to generate, create International Standard Serial Number image in Font applications.
www.OnBarcode.com
This new version of possible_responses checks to see if the pattern contains an asterisk, and if so, extracts the correct part of the source sentence to use into matching_section, switches the pronouns on that section, and then substitutes that into each relevant phrase.
Creating Data Matrix 2d Barcode In Objective-C
Using Barcode drawer for iPad Control to generate, create DataMatrix image in iPad applications.
www.OnBarcode.com
Decoding DataMatrix In VB.NET
Using Barcode reader for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
Playing with the Bot
Printing Code 128 Code Set C In Objective-C
Using Barcode encoder for iPhone Control to generate, create Code128 image in iPhone applications.
www.OnBarcode.com
Drawing QR Code 2d Barcode In .NET Framework
Using Barcode printer for ASP.NET Control to generate, create QR Code image in ASP.NET applications.
www.OnBarcode.com
You have the basic methods implemented in the Bot class, so let s play with it as-is before looking at extending it any further. The first step is to prepare a better set of data for the bot to use so that your conversations can be more engaging than those with the dummy test data shown earlier in this chapter.
Code 128A Recognizer In Java
Using Barcode reader for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
EAN-13 Decoder In None
Using Barcode decoder for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
Fred: Your Bot s Personality
QR Code Creation In None
Using Barcode maker for Word Control to generate, create QR image in Word applications.
www.OnBarcode.com
PDF 417 Creator In Java
Using Barcode drawer for Android Control to generate, create PDF 417 image in Android applications.
www.OnBarcode.com
In this section you re going to tweak the bot_data_to_yaml.rb script you created earlier to generate a YAML file for your first bot to use. Its name will be Fred and you ll generate a bot data file called fred.bot. Here s bot_data_to_yaml.rb extended with a better set of phrases and substitutions:
Encode ECC200 In Visual Basic .NET
Using Barcode generation for .NET Control to generate, create Data Matrix 2d barcode image in .NET framework applications.
www.OnBarcode.com
Barcode Reader In Java
Using Barcode decoder for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
require 'yaml' bot_data = { :presubs => [ ["dont", "do not"], ["don't", "do not"], ["youre", "you're"], ["love", "like"], ["apologize", "are sorry"], ["dislike", "hate"], ["despise", "hate"], ["yeah", "yes"], ["mom", "family"] ], :responses => { :default => [ "I don't understand.", "What ", "Huh ", "Tell me about something else.", "I'm tired of this. Change the subject." ],
GTIN - 12 Scanner In VB.NET
Using Barcode recognizer for VS .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
Recognize Code39 In Visual Studio .NET
Using Barcode decoder for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
CHAPTER 12 TYING IT TOGETHER: DEVELOPING A LARGER RUBY APPLICATION
:greeting
=> [ "Hi. I'm [name]. Want to chat ", "What's on your mind today ", "Hi. What would you like to talk about " ], :farewell => ["Good bye!", "Au revoir!"], 'hello' => [ "How's it going ", "How do you do ", "Enough of the pleasantries!" ], 'sorry' => ["There's no need to apologize."], 'different' => [ "How is it different ", "What has changed " ], 'everyone *' => ["You think everyone * "], 'do not know'=> ["Are you always so indecisive "], 'yes' => [ "At least you're positive about something!", "Great." ], 'family' => ["Tell me about your family"], 'you are *' => [ "What makes you think I am * ", "Are you so sure I am * " ], 'i am *' => [ "Is it normal for you to be * ", "Do you like being * " ], 'i do not *' => ["Why don't you * "], 'what' => ["Why do you ask ", "Why ", "I don't know. Do you "], 'no' => [ "Really ", "Fair enough." ], 'why does *' => [ "I don't know why *", "Do you already know the answer " ], 'why can\'t i *' => ["Do you want to * "],
Copyright © OnBarcode.com . All rights reserved.