blib/lib/Hailo/Role/Storage.pm

filter: Statementstmt 100% 23 / 23 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 100% 28 / 28 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Hailo/Role/Engine.pm ↑ Summary blib/lib/Hailo/Role/UI.pm »
1 package Hailo::Role::Storage;
2 29 our $AUTHORITY = 'cpan:AVAR';
3 29 $Hailo::Role::Storage::VERSION = '0.73';
4 29 ▶use v5.28.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 29 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 29 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 29 has brain => (
9 isa => 'Str',
10 is => 'rw',
11 );
12  
13 29 has order => (
14 isa => 'Int',
15 is => 'rw',
16 );
17  
18 29 has hailo => (
19 isa => 'HashRef',
20 is => 'ro',
21 documentation => "Miscellaneous private callbacks that Hailo provides to communicate with it",
22 );
23  
24 29 has tokenizer_class => (
25 isa => 'Str',
26 is => 'rw',
27 );
28  
29 29 requires 'ready';
30 29 requires 'initialized';
31 29 requires 'save';
32 29 requires 'start_learning';
33 29 requires 'stop_learning';
34 29 requires 'start_training';
35 29 requires 'stop_training';
36  
37 sub save {
38 # does nothing by default
39 5 ▶ return;
Subroutine save: called CC=1 SCAR=0.0
Pod documented
40 }
41  
42 29 1;
43  
44 =encoding utf8
45  
46 =head1 NAME
47  
48 Hailo::Role::Storage - A role representing a L<Hailo|Hailo> storage backend
49  
50 =head1 ATTRIBUTES
51  
52 =head2 C<ready>
53  
54 Ask the storage backend if it considers itself ready to go. E.g. a
55 storage that requires a C<brain> would return false if it wasn't
56 passed one.
57  
58 =head2 C<initialized>
59  
60 If you're connecting to an existing storage that already has a
61 populated schema and is ready to go this'll return true.
62  
63 =head2 C<order>
64  
65 The Markov order (chain length) being used.
66  
67 =head2 C<brain>
68  
69 The name of the resource (file name, database name) to use as storage.
70  
71 =head1 METHODS
72  
73 =head2 C<new>
74  
75 This is the constructor. It accept the attributes specified in
76 L</ATTRIBUTES>.
77  
78 =head2 C<save>
79  
80 Saves the current state.
81  
82 =head2 C<learn_tokens>
83  
84 Learns from a sequence of tokens. Takes an array reference of strings.
85  
86 =head2 C<make_reply>
87  
88 Takes an (optional) array reference of tokens and returns a reply (arrayref
89 of tokens) that might be relevant.
90  
91 =head2 C<token_total>
92  
93 Takes no arguments. Returns the number of tokens the brain knows.
94  
95 =head2 C<expr_total>
96  
97 Takes no arguments. Returns the number of expressions the brain knows.
98  
99 =head2 C<start_learning>
100  
101 Takes no arguments. This method is called by L<Hailo|Hailo> right before learning
102 begins.
103  
104 =head2 C<stop_learning>
105  
106 Takes no arguments. This method is called by L<Hailo|Hailo> right after learning
107 finishes.
108  
109 =head2 C<start_training>
110  
111 Takes no arguments. This method is called by L<Hailo|Hailo> right before training
112 begins.
113  
114 =head2 C<stop_training>
115  
116 Takes no arguments. This method is called by L<Hailo|Hailo> right after training
117 finishes.
118  
119 =head1 AUTHOR
120  
121 Hinrik E<Ouml>rn SigurE<eth>sson, hinrik.sig@gmail.com
122  
123 =head1 LICENSE AND COPYRIGHT
124  
125 Copyright 2010 Hinrik E<Ouml>rn SigurE<eth>sson
126  
127 This program is free software, you can redistribute it and/or modify
128 it under the same terms as Perl itself.
129  
130 =cut
« blib/lib/Hailo/Role/Engine.pm ↑ Summary blib/lib/Hailo/Role/UI.pm »