String::CaseProfile is a Perl module that provides a convenient way of handling the recasing (letter case conversion) of sentences/phrases/chunks in machine translation, case-sensitive search and replace, and other text processing applications.
SYNOPSIS
use String::CaseProfile qw(get_profile set_profile copy_profile);
my $reference_string = 'Some reference string';
my $string = 'sample string';
# Typical, single-line usage
my $target_string = set_profile($string, get_profile($reference_string));
# Alternatively, you can use the 'copy_profile' convenience function:
my $target_string = copy_profile(
from => $reference_string,
to => $string,
);
# Get the profile of a string and access the details
my %ref_profile = get_profile($reference_string);
my $string_type = $ref_profile{string_type};
my $profile_str = $ref_profile{fold}; # 'fll'
my $word = $ref_profile{words}[2]->{word}; # third word
my $word_type = $ref_profile{words}[2]->{type};
# See a profile report
print "$ref_profile{report}"; # No need to add \n
# Apply the profile to another string
my $new_string = set_profile($string, %ref_profile);
# Use custom profiles
my %profile1 = ( string_type => '1st_uc' );
$new_string = set_profile($string, %profile1);
my %profile2 = ( string_type => 'all_lc', force_change => 1 );
$new_string = set_profile($string, %profile2);
my %profile3 = (
custom => {
default => 'all_lc',
all_uc => '1st_uc',
index => {
3 => '1st_uc',
5 => 'all_lc',
},
}
);
$new_string = set_profile($string, %profile3);
Product's homepage
Requirements:
· Perl