Bart Lateur wrote:
> When thinking of a user-friendly interface to let a user define a table
> of words and their hyphenated forms, I stumbled across this cute
> problem. It's simple enough to be a fun puzzle, yet not too hard to be
> labour. It might even be a fun task for Perl Golf.
> 
> The problem is this: given two versions of a word, one without, and one
> with hyphenation, determine which hyphens are soft hyphens (optional
> breakpoints), and which ones are hard hyphens? For example:
> 
>       hypo-allergeen  hy-po-al-ler-geen
> 
> (If you wonder about the hyphenation rules: Dutch)
> 
> Here, all hyphens are soft hyphens, except the one between the "o" and
> the "a", which is required (I guess. I'm not 100% about the spelling,
> people seem to disagree on that one), or at least, let's suppose so.
> 
> So, a short and sweet snippet that figures this out, please? The result
> may be whatever form you like.
> 

This is cheating because it uses a non-core module, but here's a short
one that removes the soft hyphens:

perl -le'use Algorithm::Diff LCS;print LCS map[/./g],@ARGV'
       hy-po-al-ler-geen hypo-allergeen

output:
hypo-allergeen

Chris

Reply via email to