home/baden/Text-Munge-Consonants-0.1/Changes0100664000076400007640000000014407454733763017726 0ustar badenbadenRevision history for Perl extension Text::Munge::Consonants 0.1 Wed 10 April 2002 - first release home/baden/Text-Munge-Consonants-0.1/Consonants.pm0100664000076400007640000000544507454734665021131 0ustar badenbadenpackage Text::Munge::Consonants; require 5.000; require Exporter; =head1 NAME Text::Munge::Consonants - removes consonants from text =head1 SYNOPSIS use Text::Munge::Consonants; $obj = new Text::Munge::Consonants(); $obj->add_stopwords LIST $string = $obj->munge LIST =head1 DESCRIPTION Text::Munge::Consonants strips consonant spaces from words and phrases in a text input file =head1 EXAMPLE use Text::Munge::Consonants(); $munger = new Text::Munge::Consonants(); $text = "This sentence will have some of it\'s consonants removed."; print $munger->munge($text), "\n"; =head1 AUTHOR Baden Hughes Broadly based on the Text::Munge::Vowels module by Robert Rothenberg =cut use vars qw($VERSION $LANGUAGE $MinLength $MungeRule @StopWords); $VERSION = "0.5.1"; $LANGUAGE = "en-US"; # language code (for rules and stop words) @ISA = qw(Exporter); @EXPORT = qw(); use Carp; # defines the minimum length of a text sequence that must be retained through the processing my $DefaultMinLength = 4; # What do you want to strip out ? Several examples below ... other modules should be made for these # my $DefaultMungeRule = '\B[aeiouy]\B'; # only strip inner vowels # my $DefaultMungeRule = '[aeiouy]'; # strip all vowels # my $DefaultMungeRule = '\B[aeiouy]\B'; # only strip inner vowels # my $DefaultMungeRule = '\B[bcdfghjklmnpqrstvwxyz]\B'; # only strip inner consonants # my $DefaultMungeRule = '\B[bcdfghjklmnpqrstvwxyz]\B'; # strip all consonants my $DefaultMungeRule = '\B[bcdfghjklmnpqrstvwxyz]\B'; # only strip inner consonants # Add your own words here if you want some left in the text my @DefaultStopWords = qw(); sub initialize { my $self = shift; $self{VERSION} = $VERSION; $self{LANGUAGE} = $LANGUAGE; $self{MinLength} = $DefaultMinLength; $self{MungeRule} = $DefaultMungeRule; $self{StopWords} = \@DefaultStopWords; } sub new { my $this = shift; my $class = ref($this) || $this; my $self = {}; bless $self, $class; $self->initialize(); return $self; } sub import { my $self = shift; export $self; my @imports = @_; if (@imports) { carp "import() ignored in ".__PACKAGE__." v$VERSION"; } } sub add_stopwords { my $self = shift; # yes this adds duplicate words, but for this version it does not matter my @words= @_; foreach (@words) { push @{$self{StopWords}}, $_; } } sub munge { my $self = shift; my $phrase = shift; my $word, $buffer=''; foreach $word (split /\b/, $phrase) { unless ((length($word)<$self{MinLength}) or (grep (/\b$word\b/i, @{$self{StopWords}} ))) { $word =~ s/$self{MungeRule}//ig; } $buffer .= $word; } return $buffer; } 1; __END__ home/baden/Text-Munge-Consonants-0.1/MANIFEST0100664000076400007640000000007207454734065017560 0ustar badenbadenChanges Makefile.PL MANIFEST README test.pl Consonants.pm home/baden/Text-Munge-Consonants-0.1/Makefile.PL0100664000076400007640000000021507454734037020377 0ustar badenbadenuse ExtUtils::MakeMaker; WriteMakefile( 'NAME' => 'Text::Munge::Consonants', 'VERSION_FROM' => 'Consonants.pm', # finds $VERSION ); home/baden/Text-Munge-Consonants-0.1/README0100664000076400007640000000132207454735101017276 0ustar badenbadenNAME Text::Munge::Consonants - removes consonants from words phrases SYNOPSIS use Text::Munge::Consonants; $obj = new Text::Munge::Consonants(); $obj->add_stopwords LIST $string = $obj->munge LIST DESCRIPTION Text::Munge::Consonants strips consonant spaces from words and phrases to shorten the length of an input text. EXAMPLE use Text::Munge::Consonants(); $munger = new Text::Munge::Consonants(); $text = "This sentence will have some of it\'s consonants removed."; print $munger->munge($text), "\n"; AUTHOR Baden Hughes Broadly based on Text::Munge::Vowels by Robert Rothenberg home/baden/Text-Munge-Consonants-0.1/test.pl0100664000076400007640000000125407454733625017747 0ustar badenbaden# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### We start with some black magic to print on failure. # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) BEGIN { $| = 1; print "1..1\n"; } END {print "not ok 1\n" unless $loaded;} use Text::Munge::Vowels; $loaded = 1; print "ok 1\n"; ######################### End of black magic. # Insert your test code below (better if it prints "ok 13" # (correspondingly "not ok 13") depending on the success of chunk 13 # of the test code):