| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Acme::CorpusScrambler; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
29722
|
use warnings; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
114
|
|
|
4
|
4
|
|
|
4
|
|
22
|
use strict; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
130
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
4517
|
use Text::Greeking::zh_TW; |
|
|
4
|
|
|
|
|
111579
|
|
|
|
4
|
|
|
|
|
941
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Acme::CorpusScrambler - An Acme way doing Lorem Ipsum. |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
version 0.04 |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use Acme::CorpusScrambler; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $foo = Acme::CorpusScrambler->new(); |
|
25
|
|
|
|
|
|
|
my $text = $foo->scramble; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 new |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Object constructor, no parameters required. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new { |
|
36
|
3
|
|
|
3
|
1
|
33
|
my $class = shift; |
|
37
|
3
|
|
|
|
|
14
|
bless {}, $class; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 feed( $keyword => $corpus ) |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Feeds the $corpus to object, indexed by $keyword. The corpus is used latter as scrambling |
|
43
|
|
|
|
|
|
|
material. |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my %corpushash; |
|
48
|
|
|
|
|
|
|
sub feed { |
|
49
|
8
|
|
|
8
|
1
|
109859
|
my ($self, $keyword, $corpus) = @_; |
|
50
|
8
|
|
|
|
|
56
|
$corpushash{"$keyword"}="$corpus"; |
|
51
|
8
|
|
|
|
|
27
|
$self; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 scramble( @keyword ) |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Generate a piece of lipsum text accroding to @keyword. If you didn't |
|
57
|
|
|
|
|
|
|
feed any corpus before with feed() method, it will use |
|
58
|
|
|
|
|
|
|
Text::Greeking::zh_TW's default corpus. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub scramble { |
|
63
|
6
|
|
|
6
|
1
|
13816
|
my ($self, @keyword) = @_; |
|
64
|
|
|
|
|
|
|
|
|
65
|
6
|
|
|
|
|
60
|
my $g = Text::Greeking::zh_TW->new; |
|
66
|
6
|
|
|
|
|
452
|
$g->paragraphs(3,15); |
|
67
|
6
|
|
|
|
|
43
|
$g->sentences(2,10); |
|
68
|
|
|
|
|
|
|
|
|
69
|
6
|
100
|
|
|
|
36
|
if (@keyword) { |
|
70
|
3
|
|
|
|
|
9
|
my $newcorpus = join("\n\n", @corpushash{ grep { exists $corpushash{$_} } @keyword }); |
|
|
4
|
|
|
|
|
44
|
|
|
71
|
3
|
100
|
|
|
|
18
|
if ($newcorpus) { |
|
72
|
2
|
|
|
|
|
13
|
$g->add_source($newcorpus); |
|
73
|
2
|
|
|
|
|
47
|
return $g->generate; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
1
|
|
|
|
|
5
|
return "" |
|
76
|
|
|
|
|
|
|
}else { |
|
77
|
3
|
|
|
|
|
17
|
return $g->generate; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 AUTHOR |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Kang-min Liu |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
shelling |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 BUGS |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Please report any bugs or feature requests to C or C |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 SUPPORT |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
perldoc Acme::CorpusScrambler |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
You can also look for information at: |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=over 4 |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
L |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
L |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
L |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item * Search CPAN |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
L |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=back |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Copyright @ 2007-2008 Kang-min Liu, shelling, all rights reserved. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
124
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
1; |