Ever wanted to know how often each letter appears at ends of words in French? Here's the simple way to find out.

I used the following perl command to read an utf-8 encoded text file (the novel “Les enfants du capitaine Grant” by Jules Verne), and prints the number of occurrences in word final position of each letter. The results are sorted, and besides each word I print the most frequent words ending in that word. Apostrophes and hyphens are considered word separators, so the “t” in “y a-t-il” counts as a separate word. Also, lower and upper case counts separately.

perl -we 'binmode STDIN, "encoding(utf8)" or die; binmode STDOUT, "enc +oding(utf8)" or die; while(<>) { while (/(\p{IsAlpha}+)/g) { my $w = +$1; my $l = substr $w, -1; $f{$l}++; $r{$l}{$w}++; } }; for my $l (so +rt { $f{$a} <=> $f{$b} } keys %f) { @m = reverse sort { $r{$l}{$a} <= +> $r{$l}{$b} } keys %{$r{$l}}; splice @m, 10; printf "%5d %s - %s\n", + $f{$l}, $l, join(" ", @m); }' <grantu.txt

The result is below.

1 ë - aiguë 1 U - DU 2 v - dev 2 B - B 2 G - G 2 A - A 2 P - P 2 R - R 3 T - T GRANT 3 ç - ç 5 Y - Y 9 ï - Nouï Paï Aï Mahaï Tawaï 14 E - PARTIE DEUXIÈME TROISIÈME PREMIÈRE CAPITAINE E 17 N - N 21 S - S LES ENFANTS 24 X - X XIX XX IX 25 O - O
26 û - dû 28 V - V XV IV XIV XXIV XXXV 34 b - plomb Colomb Jacob aplomb club cab Bob Rob Webb Pendjaub 47 w - Glasgow New Lucknow gow low Andrew Luknow Barrow 51 M - M MM 87 J - J 89 I - II VII I XVI XXI XIII VI XII XI XXII 93 D - D 116 k - brick Cook Black creek Carlsbrook Brunswick Norfolk Creek tr +ack sink 146 q - cinq Cinq esq 159 j - j 205 g - long sang King Darling boomerang rang poing joug sterling Pé +tersbourg 243 L - L 252 f - chef neuf sauf vif boeuf soif massif motif Bref actif 259 À - À 331 p - coup trop cap beaucoup Cap galop champ loup camp Trop 350 h - Eh Ah Oh pah Perth zénith hurrah fish Hurrah Landsborough 362 C - C 371 ù - où Où 465 m - m nom Tom Malcolm faim Amsterdam phormium William Hottam gas +trolobium 577 o - rio Waikato néo Talcahuano Taupo Colorado Antuco poncho numé +ro Callao 922 z - assez avez voulez chez catapaz voyez allez Parlez savez nez 1484 y - y lady Mary Mulrady Harry Lady Snowy Halley Paddy Bay 1690 c - avec donc c Mac lac Donc pic choc blanc tronc 3094 x - deux aux yeux eux chevaux eaux dix voix six mieux 3104 é - été côté Toliné trouvé malgré obscurité donné passé extrémit +é degré 4403 d - d quand bord lord pied sud grand nord mylord fond 4810 à - à là déjà Là Voilà voilà delà çà Déjà Çà 5247 i - qui lui si ni Oui ai moi aussi Si ainsi 7394 u - du au qu peu ou jusqu eau feu milieu Au 8886 l - l il Paganel Il sol ciel soleil seul cheval animal 9903 a - la sa a La Helena demanda écria Britannia cha cela 10932 r - sur par pour major leur mer car jour avoir soir 15718 n - un en Glenarvan n son John on bien Ayrton On 32008 t - et est était dit répondit avait fut Grant tout Robert 41984 s - les des s pas dans ses plus vous ces nous 50004 e - de le une se que ne ce Le cette je

In reply to Final letter frequency by ambrus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.