line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Eliza::Chatbot::Option; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
66447
|
use Moo; |
|
10
|
|
|
|
|
11394
|
|
|
10
|
|
|
|
|
58
|
|
4
|
10
|
|
|
10
|
|
4749
|
use MooX::LazierAttributes; |
|
10
|
|
|
|
|
18332
|
|
|
10
|
|
|
|
|
59
|
|
5
|
10
|
|
|
10
|
|
6760
|
use Eliza::Chatbot::ScriptParser; |
|
10
|
|
|
|
|
45
|
|
|
10
|
|
|
|
|
2615
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
attributes ( |
8
|
|
|
|
|
|
|
[qw/script_file debug_text transform_text botprompt userprompt/] => [ rw, '', {lzy}], |
9
|
|
|
|
|
|
|
[qw/prompts_on memory_on likelihood_of_using_memory/] => [ rw, 1, {lzy}], |
10
|
|
|
|
|
|
|
name => [ rw, 'Eliza', {lzy}], |
11
|
|
|
|
|
|
|
debug => [rw, 0, {lzy}], |
12
|
|
|
|
|
|
|
max_memory_size => [rw, 5, {lzy}], |
13
|
|
|
|
|
|
|
memory => [rw, [ ], {lzy}], |
14
|
|
|
|
|
|
|
data => [ro, nan, {lzy, bld}] |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _build_data { |
18
|
23
|
|
|
23
|
|
26869
|
my $self = shift; |
19
|
23
|
|
|
|
|
393
|
my $parser = Eliza::Chatbot::ScriptParser->new(script_file => $self->script_file); |
20
|
23
|
|
|
|
|
11832
|
$parser->parse_script_data; |
21
|
23
|
|
|
|
|
608
|
return $parser; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub myrand { |
25
|
11
|
|
|
11
|
1
|
151
|
my ($self, $max) = @_; |
26
|
11
|
50
|
|
|
|
39
|
my $n = defined $max ? $max : 1; |
27
|
11
|
|
|
|
|
211
|
return rand($n); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub welcome_message { |
31
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
32
|
0
|
|
|
|
|
|
my $initial = $self->data->initial; |
33
|
0
|
|
|
|
|
|
return $initial->[ $self->myrand( scalar @{$initial} ) ]; |
|
0
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__END__ |