File Coverage

blib/lib/Hailo/Role/Storage.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 18 18 100.0


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