| Hailo documentation | Contained in the Hailo distribution. |
Hailo::Tokenizer::Chars - A character tokenizer for Hailo
This tokenizer dumbly splits input with split //. Use it to
generate chains on a per-character basis.
Ævar Arnfjörð Bjarmason <avar@cpan.org>
Copyright 2010 Ævar Arnfjörð Bjarmason.
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
| Hailo documentation | Contained in the Hailo distribution. |
package Hailo::Tokenizer::Chars; BEGIN { $Hailo::Tokenizer::Chars::AUTHORITY = 'cpan:AVAR'; } BEGIN { $Hailo::Tokenizer::Chars::VERSION = '0.69'; } use 5.010; use Any::Moose; use Any::Moose 'X::StrictConstructor'; use namespace::clean -except => 'meta'; with qw(Hailo::Role::Arguments Hailo::Role::Tokenizer); # output -> tokens sub make_tokens { my ($self, $line) = @_; my @chars = split //, $line; my @tokens = map { [$self->{_spacing_normal}, $_] } @chars; return \@tokens; } # tokens -> output sub make_output { my ($self, $tokens) = @_; return trim(join '', map { $_->[1] } @$tokens); } sub trim { my $txt = shift; $txt =~ s/^\s+//; $txt =~ s/\s+$//; return $txt; } __PACKAGE__->meta->make_immutable;