?? polite.pm
字號:
package Chatbot::Eliza::Polite;use Chatbot::Eliza;use vars '@ISA';# file: Chatbot/Eliza/Polite.pm# Figure 12.3: Eliza::Chatbot::Polite module@ISA = 'Chatbot::Eliza';# return our welcome linesub welcome { my $self = shift; $self->botprompt($self->name . ":\t"); # Set Eliza's prompt $self->userprompt("you:\t"); # Set user's prompt # Generate the initial greeting return join ('', $self->botprompt, $self->{initial}->[ int rand scalar @{ $self->{initial} } ],"\n", $self->userprompt);}# Return the response to a line of user inputsub one_line { my $self = shift; my $in = shift; my $reply; # If the user wants to quit, # print out a farewell and quit. if ( $self->_testquit($in) ) { $reply = $self->{final}->[ int rand scalar @{ $self->{final} } ]; $self->{_quit}++; # flag that we're done return $reply . "\n"; } # Invoke the transform method # to generate a reply. $reply = $self->transform( $in ); return join ('', $self->botprompt, $reply,"\n", $self->userprompt);}# Return true if the session is donesub done { return shift->{_quit} }1;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -