Save your juncture rules in a hash.
my %juncture_of = ( inm => 'imm', # immature abt => 'abst', # abstract adt => 'att', # attempt # etc. ); sub join_euphoniously { my $compound = join '', @_; while ( my ($raw, $joined) = each %juncture_of ) { $compound =~ s/$raw/$joined/; } return $compound; } sub unjoin { my $compound = shift; # maybe no juncture rules applied to this one my @possibilities = ( $compound ); # analyze whether $string resulted from a juncture rule while (my ($raw, $joined) = each %juncture_of ) { for my $possibility (@possibilities) { if ( $possibility =~ s/$joined/$raw/ ) { push @possibilities, $possibility } } } return \@possibilities; }
Still to do: decompose each possibility into dictionary words.
In reply to Re: unglue words joined together by juncture rules
by Narveson
in thread unglue words joined together by juncture rules
by pc2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |