Filename | /mnt/stuff/src/my-cpan/hailo/lib/Hailo/Role/Storage.pm |
Statements | Executed 20 statements in 311µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 70µs | 161µs | BEGIN@3 | Hailo::Role::Storage::
1 | 1 | 1 | 18µs | 91µs | BEGIN@3.15 | Hailo::Role::Storage::
1 | 1 | 1 | 12µs | 1.36ms | BEGIN@5 | Hailo::Role::Storage::
1 | 1 | 1 | 12µs | 404µs | BEGIN@4 | Hailo::Role::Storage::
0 | 0 | 0 | 0s | 0s | save | Hailo::Role::Storage::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Hailo::Role::Storage; | ||||
2 | |||||
3 | 4 | 90µs | 3 | 325µs | use 5.010; # spent 161µs making 1 call to Hailo::Role::Storage::BEGIN@3
# spent 91µs making 1 call to Hailo::Role::Storage::BEGIN@3.15
# spent 73µs making 1 call to feature::import |
4 | 2 | 32µs | 2 | 795µs | # spent 404µs (12+392) within Hailo::Role::Storage::BEGIN@4 which was called:
# once (12µs+392µs) by Mouse::Util::_try_load_one_class at line 4 # spent 404µs making 1 call to Hailo::Role::Storage::BEGIN@4
# spent 392µs making 1 call to Any::Moose::import |
5 | 2 | 133µs | 2 | 2.71ms | # spent 1.36ms (12µs+1.35) within Hailo::Role::Storage::BEGIN@5 which was called:
# once (12µs+1.35ms) by Mouse::Util::_try_load_one_class at line 5 # spent 1.36ms making 1 call to Hailo::Role::Storage::BEGIN@5
# spent 1.35ms making 1 call to namespace::clean::import |
6 | |||||
7 | 1 | 4µs | 1 | 35µs | has brain => ( # spent 35µs making 1 call to Mouse::Role::has |
8 | isa => 'Str', | ||||
9 | is => 'rw', | ||||
10 | ); | ||||
11 | |||||
12 | 1 | 3µs | 1 | 30µs | has order => ( # spent 30µs making 1 call to Mouse::Role::has |
13 | isa => 'Int', | ||||
14 | is => 'rw', | ||||
15 | ); | ||||
16 | |||||
17 | 1 | 3µs | 1 | 30µs | has hailo => ( # spent 30µs making 1 call to Mouse::Role::has |
18 | isa => 'HashRef', | ||||
19 | is => 'ro', | ||||
20 | documentation => "Miscellaneous private callbacks that Hailo provides to communicate with it", | ||||
21 | ); | ||||
22 | |||||
23 | 1 | 3µs | 1 | 30µs | has tokenizer_class => ( # spent 30µs making 1 call to Mouse::Role::has |
24 | isa => 'Str', | ||||
25 | is => 'rw', | ||||
26 | ); | ||||
27 | |||||
28 | 1 | 4µs | 1 | 68µs | requires 'ready'; # spent 68µs making 1 call to Mouse::Role::requires |
29 | 1 | 4µs | 1 | 52µs | requires 'initialized'; # spent 52µs making 1 call to Mouse::Role::requires |
30 | 1 | 3µs | 1 | 55µs | requires 'save'; # spent 55µs making 1 call to Mouse::Role::requires |
31 | 1 | 3µs | 1 | 51µs | requires 'start_learning'; # spent 51µs making 1 call to Mouse::Role::requires |
32 | 1 | 4µs | 1 | 51µs | requires 'stop_learning'; # spent 51µs making 1 call to Mouse::Role::requires |
33 | 1 | 3µs | 1 | 51µs | requires 'start_training'; # spent 51µs making 1 call to Mouse::Role::requires |
34 | 1 | 3µs | 1 | 54µs | requires 'stop_training'; # spent 54µs making 1 call to Mouse::Role::requires |
35 | |||||
36 | sub save { | ||||
37 | # does nothing by default | ||||
38 | return; | ||||
39 | } | ||||
40 | |||||
41 | 1 | 10µs | 1; | ||
42 | |||||
43 | =encoding utf8 | ||||
44 | |||||
45 | =head1 NAME | ||||
46 | |||||
47 | Hailo::Role::Storage - A role representing a L<Hailo|Hailo> storage backend | ||||
48 | |||||
49 | =head1 ATTRIBUTES | ||||
50 | |||||
51 | =head2 C<ready> | ||||
52 | |||||
53 | Ask the storage backend if it considers itself ready to go. E.g. a | ||||
54 | storage that requires a C<brain> would return false if it wasn't | ||||
55 | passed one. | ||||
56 | |||||
57 | =head2 C<initialized> | ||||
58 | |||||
59 | If you're connecting to an existing storage that already has a | ||||
60 | populated schema and is ready to go this'll return true. | ||||
61 | |||||
62 | =head2 C<order> | ||||
63 | |||||
64 | The Markov order (chain length) being used. | ||||
65 | |||||
66 | =head2 C<brain> | ||||
67 | |||||
68 | The name of the resource (file name, database name) to use as storage. | ||||
69 | |||||
70 | =head1 METHODS | ||||
71 | |||||
72 | =head2 C<new> | ||||
73 | |||||
74 | This is the constructor. It accept the attributes specified in | ||||
75 | L</ATTRIBUTES>. | ||||
76 | |||||
77 | =head2 C<save> | ||||
78 | |||||
79 | Saves the current state. | ||||
80 | |||||
81 | =head2 C<learn_tokens> | ||||
82 | |||||
83 | Learns from a sequence of tokens. Takes an array reference of strings. | ||||
84 | |||||
85 | =head2 C<make_reply> | ||||
86 | |||||
87 | Takes an (optional) array reference of tokens and returns a reply (arrayref | ||||
88 | of tokens) that might be relevant. | ||||
89 | |||||
90 | =head2 C<token_total> | ||||
91 | |||||
92 | Takes no arguments. Returns the number of tokens the brain knows. | ||||
93 | |||||
94 | =head2 C<expr_total> | ||||
95 | |||||
96 | Takes no arguments. Returns the number of expressions the brain knows. | ||||
97 | |||||
98 | =head2 C<start_learning> | ||||
99 | |||||
100 | Takes no arguments. This method is called by L<Hailo|Hailo> right before learning | ||||
101 | begins. | ||||
102 | |||||
103 | =head2 C<stop_learning> | ||||
104 | |||||
105 | Takes no arguments. This method is called by L<Hailo|Hailo> right after learning | ||||
106 | finishes. | ||||
107 | |||||
108 | =head2 C<start_training> | ||||
109 | |||||
110 | Takes no arguments. This method is called by L<Hailo|Hailo> right before training | ||||
111 | begins. | ||||
112 | |||||
113 | =head2 C<stop_training> | ||||
114 | |||||
115 | Takes no arguments. This method is called by L<Hailo|Hailo> right after training | ||||
116 | finishes. | ||||
117 | |||||
118 | =head1 AUTHOR | ||||
119 | |||||
120 | Hinrik E<Ouml>rn SigurE<eth>sson, hinrik.sig@gmail.com | ||||
121 | |||||
122 | =head1 LICENSE AND COPYRIGHT | ||||
123 | |||||
124 | Copyright 2010 Hinrik E<Ouml>rn SigurE<eth>sson | ||||
125 | |||||
126 | This program is free software, you can redistribute it and/or modify | ||||
127 | it under the same terms as Perl itself. | ||||
128 | |||||
129 | 1 | 9µs | 1 | 4.34ms | =cut # spent 4.34ms making 1 call to B::Hooks::EndOfScope::__ANON__[B/Hooks/EndOfScope.pm:26] |