hello people,

Here is a little raku code to count all the digraphs from some text:

        my %digraphs =
        slurp.lc
        .comb(/<[a..z]>+/)
        .map( *.comb.rotor( 2 => -1, :!partial ).map: *.join )
        .Bag;

The first .comb match words then I map them to get digraphs but I think
it is possible to move the cursor backward in the comb regex. I just
don't know how. I'm trying to write something like:

        slurp.lc
        .comb(/ <[a..z]> ** 2 { --pos } /)
        .Bag;

The perl version of it is:

perl -lnE '
        END { say "$_ = $digraph{$_}" for
                sort { $digraph{$b} <=> $digraph{$a} }
                keys %digraph
        }
        $_=lc; while (/([a-z]{2})/g) {++$digraph{$1}; --pos; }
'

Any help is very welcome.

regards,

-- 
Marc Chantreux
Pôle de Calcul et Services Avancés à la Recherche (CESAR)
http://annuaire.unistra.fr/p/20200

Reply via email to