Hello...I have a few problem. I have txt file like this:
Quote:
00 21 55 84 9a ff 00 1f 9e 1a 5b 00 08 00 45 00 00 4b 00 00 40 00 3f 11 9a 0e a1 8b fa 02 04 02
|
Then, based on my txt file, I would like to generate text like this:
Quote:
00215584 2155849a 55849aff 849aff00 9aff001f ff001f9e 001f9e1a 1f9e1a5b 9e1a5b00 1a5b0008 5b000800 00080045 08004500 00450000 00004b00 004b0000 4b000040 00004000 0040003f 40003f11 003f119a 3f119a0e 119a0ea1 9a0ea18b 0ea18bfa a18bfa02
|
Based in my reading, I found about ngram solution in perl, but I not really understand to edit from source code given. I m begineer user in programming language. I hope to get the solution.
This is ngram source code in .pm (
http://search.cpan.org/~simon/Text-Ngram-0.03/Ngram.pm):
Quote:
package Text::Ngram;
use 5.006;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
our %EXPORT_TAGS = ( 'all' => [ qw( ngram_counts add_to_counts) ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
our $VERSION = '0.03';
require XSLoader;
XSLoader::load('Text::Ngram', $VERSION);
# Preloaded methods go here.
sub clean_buffer {
my $buffer = lc shift;
$buffer =~ s/\s+/ /g;
$buffer =~ s/[^a-z ]+/ \xff /g;
return $buffer;
}
sub ngram_counts {
my ($buffer, $width) = @_;
my $href = process_buffer(clean_buffer($buffer), $width||5);
for (keys %$href) { delete $href->{$_} if /\xff/ }
return $href;
}
sub add_to_counts {
my ($buffer, $width, $href) = @_;
if (!defined $width or !$width) {
my ($key, undef) = each %$href; # Just gimme a random key
$width = length $key || 5;
}
process_buffer_incrementally(clean_buffer($buffer), $width, $href);
for (keys %$href) { delete $href->{$_} if /\xff/ }
}
1;
|
Thank you...