| 1 | package Hailo::Tokenizer::Chars; | ||
| 2 | 3 | our $AUTHORITY = 'cpan:AVAR'; | |
| 3 | 3 | $Hailo::Tokenizer::Chars::VERSION = '0.73'; | |
| 4 | 3 | ▶ | use v5.28.0; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 3 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 3 | ▶ | use MooseX::StrictConstructor; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 3 | ▶ | use namespace::clean -except => 'meta'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 3 | with qw(Hailo::Role::Arguments | |
| 10 | Hailo::Role::Tokenizer); | ||
| 11 | |||
| 12 | # output -> tokens | ||
| 13 | sub make_tokens { | ||
| 14 | 4402 | ▶ | my ($self, $line) = @_; |
|
Subroutine
make_tokens: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 15 | 4402 | my @chars = split //, $line; | |
| 16 | 4402 | my @tokens = map { [$self->{_spacing_normal}, $_] } @chars; | |
| 17 | 4402 | return \@tokens; | |
| 18 | } | ||
| 19 | |||
| 20 | # tokens -> output | ||
| 21 | sub make_output { | ||
| 22 | 61 | ▶ | my ($self, $tokens) = @_; |
|
Subroutine
make_output: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 23 | 61 | return trim(join '', map { $_->[1] } @$tokens); | |
| 24 | } | ||
| 25 | |||
| 26 | sub trim { | ||
| 27 | 61 | ▶ | my $txt = shift; |
|
Subroutine
trim: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 28 | 61 | $txt =~ s/^\s+//; | |
| 29 | 61 | $txt =~ s/\s+$//; | |
| 30 | 61 | return $txt; | |
| 31 | } | ||
| 32 | |||
| 33 | 3 | __PACKAGE__->meta->make_immutable; | |
| 34 | |||
| 35 | =encoding utf8 | ||
| 36 | |||
| 37 | =head1 NAME | ||
| 38 | |||
| 39 | Hailo::Tokenizer::Chars - A character tokenizer for L<Hailo|Hailo> | ||
| 40 | |||
| 41 | =head1 DESCRIPTION | ||
| 42 | |||
| 43 | This tokenizer dumbly splits input with C<split //>. Use it to | ||
| 44 | generate chains on a per-character basis. | ||
| 45 | |||
| 46 | =head1 AUTHOR | ||
| 47 | |||
| 48 | E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org> | ||
| 49 | |||
| 50 | =head1 LICENSE AND COPYRIGHT | ||
| 51 | |||
| 52 | Copyright 2010 E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason. | ||
| 53 | |||
| 54 | This program is free software, you can redistribute it and/or modify | ||
| 55 | it under the same terms as Perl itself. | ||
| 56 | |||
| 57 | =cut | ||