<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: LingvoBerry</title>
    <description>The latest articles on DEV Community by LingvoBerry (lingvoberry).</description>
    <link>https://dev.to/lingvoberry</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F15746%2Feef1b678-66d8-4e95-a96f-e593895999f6.png</url>
      <title>DEV Community: LingvoBerry</title>
      <link>https://dev.to/lingvoberry</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lingvoberry"/>
    <language>en</language>
    <item>
      <title>How an importer tells Brazilian from European Portuguese</title>
      <dc:creator>LingvoBerry</dc:creator>
      <pubDate>Tue, 10 Nov 2026 13:15:56 +0000</pubDate>
      <link>https://dev.to/lingvoberry/how-an-importer-tells-brazilian-from-european-portuguese-1hcn</link>
      <guid>https://dev.to/lingvoberry/how-an-importer-tells-brazilian-from-european-portuguese-1hcn</guid>
      <description>&lt;p&gt;Our reading app serves Portuguese as Brazilian Portuguese, everywhere: &lt;code&gt;você&lt;/code&gt;, &lt;code&gt;arquivo&lt;/code&gt;, &lt;code&gt;cadastro&lt;/code&gt;, &lt;code&gt;café da manhã&lt;/code&gt;. The book generator that feeds the catalogue did not get that memo. Left to itself it wrote European Portuguese, and 29 public books had to be converted to Brazilian on the production database. The generator's original bundles were still lying around, so a single re-upload of an old file would have quietly put the European text back.&lt;/p&gt;

&lt;p&gt;The fix is a gate in the importer: a pt book that contains European forms is refused. This post walks through how that check works, what it catches, and where a regex-based language-variant detector bites.&lt;/p&gt;

&lt;h2&gt;
  
  
  The shape of the check
&lt;/h2&gt;

&lt;p&gt;The detector is a table of labelled regular expressions and a function that returns every hit with some context around it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;european_portuguese&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""[(label, snippet)] — the European Portuguese forms in `text`."""&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rx&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;PT_EUROPEAN&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;finditer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;IGNORECASE&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;UNICODE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"\n"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It returns snippets rather than a boolean because the person uploading a book needs to see &lt;em&gt;where&lt;/em&gt; the problem is. The importer turns the first hit into the error message:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;language&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"pt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;european&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;langs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;european_portuguese&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"\n"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;european&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;snippet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;european&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;BookImportError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"European Portuguese in a pt book ({len(european)} places, first: "&lt;/span&gt;
            &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{label} — «{snippet.strip()}»); Portuguese here is Brazilian only"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The table itself has six rows. The selection rule was empirical: a form goes in only if it appeared in the European versions of those 29 books and never in the Brazilian ones. That rule is why &lt;code&gt;a sua casa&lt;/code&gt; is &lt;em&gt;not&lt;/em&gt; in the table, even though textbooks list the article-before-possessive as European: Brazilian writers use it too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Six kinds of evidence
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Second-person &lt;code&gt;tu&lt;/code&gt; / &lt;code&gt;vós&lt;/code&gt; and their possessives.&lt;/strong&gt; &lt;code&gt;tu&lt;/code&gt;, &lt;code&gt;vós&lt;/code&gt;, &lt;code&gt;vosso&lt;/code&gt;, &lt;code&gt;contigo&lt;/code&gt;, &lt;code&gt;convosco&lt;/code&gt;, &lt;code&gt;teu&lt;/code&gt;, &lt;code&gt;tua&lt;/code&gt;… Brazilian prose addresses the reader with &lt;code&gt;você&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. &lt;code&gt;ter de&lt;/code&gt; + infinitive.&lt;/strong&gt; Europeans write &lt;code&gt;tenho de ir&lt;/code&gt;, Brazilians &lt;code&gt;tenho que ir&lt;/code&gt;. The pattern lists the conjugated forms of &lt;code&gt;ter&lt;/code&gt; followed by &lt;code&gt;de&lt;/code&gt; and something that ends like an infinitive (&lt;code&gt;-ar&lt;/code&gt;, &lt;code&gt;-er&lt;/code&gt;, &lt;code&gt;-ir&lt;/code&gt;, &lt;code&gt;-or&lt;/code&gt;, &lt;code&gt;-ôr&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. &lt;code&gt;estar a&lt;/code&gt; + infinitive.&lt;/strong&gt; The European progressive: &lt;code&gt;está a comer&lt;/code&gt; where Brazil says &lt;code&gt;está comendo&lt;/code&gt;. Same infinitive tail, with &lt;code&gt;ficar&lt;/code&gt;, &lt;code&gt;continuar&lt;/code&gt; and &lt;code&gt;andar&lt;/code&gt; in the verb list too.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. European vocabulary.&lt;/strong&gt; A word list: &lt;code&gt;autocarro&lt;/code&gt;, &lt;code&gt;comboio&lt;/code&gt;, &lt;code&gt;rapariga&lt;/code&gt;, &lt;code&gt;pequeno-almoço&lt;/code&gt;, &lt;code&gt;casa de banho&lt;/code&gt;, &lt;code&gt;telemóvel&lt;/code&gt;, &lt;code&gt;ecrã&lt;/code&gt;, &lt;code&gt;equipa&lt;/code&gt;, &lt;code&gt;facto&lt;/code&gt;, &lt;code&gt;ficheiro&lt;/code&gt;, &lt;code&gt;registo&lt;/code&gt; and 18 more entries, many with a &lt;code&gt;\w*&lt;/code&gt; tail to catch inflections.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. European spelling.&lt;/strong&gt; One regex: &lt;code&gt;\b\w*[óé][mn][aeiou]\w*&lt;/code&gt;. Before &lt;code&gt;m&lt;/code&gt; or &lt;code&gt;n&lt;/code&gt; followed by a vowel, Portugal writes an acute accent and Brazil a circumflex: &lt;code&gt;económico&lt;/code&gt; / &lt;code&gt;econômico&lt;/code&gt;, &lt;code&gt;fenómeno&lt;/code&gt; / &lt;code&gt;fenômeno&lt;/code&gt;, &lt;code&gt;António&lt;/code&gt; / &lt;code&gt;Antônio&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Guillemets.&lt;/strong&gt; &lt;code&gt;[«»]&lt;/code&gt;. European fiction quotes dialogue in « »; Brazilian prose uses dashes and curly quotes.&lt;/p&gt;

&lt;p&gt;Running the repository's own test sentences through the detector gives this (real output, trimmed to the label and snippet):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;EUROPEAN hits:
  tu/vós                 | Tu tens de ir já. Ela estava a c
  ter de                 | Tu tens de ir já. Ela estava a comer na cas
  estar a + infinitive   | Tu tens de ir já. Ela estava a comer na casa de banho. «Que facto
  European word          |  ir já. Ela estava a comer na casa de banho. «Que facto económico!», diss
  European word          |  comer na casa de banho. «Que facto económico!», disse a rapariga
  European word          | ue facto económico!», disse a rapariga ao pequeno-almoço.
  European word          | nómico!», disse a rapariga ao pequeno-almoço.
  European spelling      |  na casa de banho. «Que facto económico!», disse a rapariga ao pequen
  « » quotes             | ava a comer na casa de banho. «Que facto económico!», disse a
  « » quotes             | e banho. «Que facto económico!», disse a rapariga ao pequeno-
BRAZILIAN hits: []
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two sentences of European Portuguese produce ten hits across all six labels. The Brazilian control text, which deliberately includes &lt;code&gt;A sua casa fica perto&lt;/code&gt; and &lt;code&gt;a mulher dele&lt;/code&gt;, produces none.&lt;/p&gt;

&lt;h2&gt;
  
  
  The infinitive trap
&lt;/h2&gt;

&lt;p&gt;Rows 2 and 3 look for "something that ends in &lt;code&gt;-ar&lt;/code&gt; / &lt;code&gt;-er&lt;/code&gt; / &lt;code&gt;-ir&lt;/code&gt; / &lt;code&gt;-or&lt;/code&gt;". Portuguese has plenty of nouns with exactly those endings: &lt;code&gt;mulher&lt;/code&gt;, &lt;code&gt;lugar&lt;/code&gt;, &lt;code&gt;mar&lt;/code&gt;, &lt;code&gt;olhar&lt;/code&gt;, &lt;code&gt;jantar&lt;/code&gt;, &lt;code&gt;prazer&lt;/code&gt;. So &lt;code&gt;ela está a mulher mais alta&lt;/code&gt; would look like the European progressive.&lt;/p&gt;

&lt;p&gt;The pattern guards against that with a negative lookahead in front of the infinitive:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;_NOT_INFINITIVE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"(?!(?:mulher|colher|lugar|mar|ar|bar|altar|olhar|luar|lar|par|prazer|"&lt;/span&gt;
                   &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"poder|dever|açúcar|militar|familiar|particular|popular|jantar|talher)\b)"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;_INF&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_NOT_INFINITIVE&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"\w*(?:ar|er|ir|ôr|or)\b"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;\b&lt;/code&gt; inside the lookahead matters: without it, &lt;code&gt;mar&lt;/code&gt; would also exclude &lt;code&gt;marcar&lt;/code&gt; and &lt;code&gt;ar&lt;/code&gt; would exclude every infinitive in the language. Some probes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'Ela tem de comprar pão.'                -&amp;gt; ['ter de']
'A sala tem de lugar para dez.'          -&amp;gt; []
'Ela está a comer.'                      -&amp;gt; ['estar a + infinitive']
'Ela está a mulher mais alta.'           -&amp;gt; []
'A parede tem de cor branca.'            -&amp;gt; ['ter de']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last line is a miss in the other direction: &lt;code&gt;cor&lt;/code&gt; (colour) ends in &lt;code&gt;-or&lt;/code&gt; and is not on the exclusion list. The sentence is clumsy Portuguese and never came up in the books, which is how a list like this grows: one real false positive at a time, not by trying to enumerate the lexicon up front.&lt;/p&gt;

&lt;h2&gt;
  
  
  The spelling trap
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;\b\w*[óé][mn][aeiou]\w*&lt;/code&gt; is the bluntest row. It leaves the common Brazilian words alone because their accented vowel sits at the end of the word, with no vowel after the nasal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'Também, porém, alguém, ninguém.'        -&amp;gt; []
'Ele mora em Belém.'                     -&amp;gt; []
'O fenómeno económico.'                  -&amp;gt; ['European spelling', 'European spelling']
'O fenômeno econômico.'                  -&amp;gt; []
'A Mónica e o António.'                  -&amp;gt; ['European spelling', 'European spelling']
'A Mônica e o Antônio.'                  -&amp;gt; []
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But it knows nothing about loanwords:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'O menino jogava Pokémon.'               -&amp;gt; ['European spelling']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A Brazilian children's story that mentions Pokémon would be refused. The row is still worth its keep: the importer is a gate in front of a content pipeline, not a classifier facing arbitrary user text, so a false positive costs one human a second look, and the error message carries the snippet, so that look takes seconds. If loanwords start showing up, the fix is the same lookahead trick as above.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why a table and not a classifier
&lt;/h2&gt;

&lt;p&gt;The requirement is narrow and strict: one pipeline must never put a known set of forms back into the catalogue. A table built from the actual bad bundles explains every refusal by label and snippet and runs in microseconds. The generator holds the same table for its own gate, so both ends of the pipeline agree on what "European" means.&lt;/p&gt;

&lt;h2&gt;
  
  
  The tests
&lt;/h2&gt;

&lt;p&gt;Three tests in &lt;code&gt;test_pt_brazilian.py&lt;/code&gt; pin the behaviour:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;test_each_european_form_is_found_and_brazilian_text_is_clean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;labels&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;langs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;european_portuguese&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;EUROPEAN&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;labels&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;langs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;PT_EUROPEAN&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;langs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;european_portuguese&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;BRAZILIAN&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first assertion compares against the table's own labels, so adding a row without extending the European sample sentence fails the test. The other two run the real importer in dry-run mode: a European bundle raises &lt;code&gt;BookImportError&lt;/code&gt; matching "European Portuguese", while the Brazilian bundle imports and the same European text tagged as Spanish passes, because the check only runs for &lt;code&gt;pt&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;============================== 3 passed in 0.14s ===============================
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The books this gate protects are on the &lt;a href="https://lingvoberry.com/read/pt?l=4f7e24" rel="noopener noreferrer"&gt;Portuguese shelf of graded readers&lt;/a&gt;, from A0 to C1, all in Brazilian Portuguese.&lt;/p&gt;

&lt;p&gt;This article was drafted with AI assistance; we ran the code and checked every figure and claim before publishing.&lt;/p&gt;

</description>
      <category>python</category>
      <category>nlp</category>
      <category>testing</category>
      <category>languages</category>
    </item>
    <item>
      <title>Your German word list has no ß (and your stats may be lying because of it)</title>
      <dc:creator>LingvoBerry</dc:creator>
      <pubDate>Sat, 31 Oct 2026 14:19:41 +0000</pubDate>
      <link>https://dev.to/lingvoberry/your-german-word-list-has-no-ss-and-your-stats-may-be-lying-because-of-it-471h</link>
      <guid>https://dev.to/lingvoberry/your-german-word-list-has-no-ss-and-your-stats-may-be-lying-because-of-it-471h</guid>
      <description>&lt;p&gt;Here is a one-liner that broke a report of ours:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;wordfreq&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;tokenize&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;tokenize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Er weiß, dass die Straße groß ist&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;de&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;er&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;weiss&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;dass&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;die&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;strasse&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;gross&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ist&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;wordfreq&lt;/code&gt; is a good library and this isn't a bug: it looks like ordinary case-folding, since &lt;code&gt;"ß".casefold()&lt;/code&gt; gives &lt;code&gt;"ss"&lt;/code&gt;. It still surprised us, because the output is spelled in a way a German book never spells these words.&lt;/p&gt;

&lt;h2&gt;
  
  
  How far it goes
&lt;/h2&gt;

&lt;p&gt;We were using version 3.1.1, and the list has no ß in it at all:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;wordfreq&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;top_n_list&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;word_frequency&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ß&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;top_n_list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;de&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50_000&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;word_frequency&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;weiß&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;de&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nf"&gt;word_frequency&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;weiss&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;de&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;top_n_list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;de&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;weiss&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="mi"&gt;166&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So asking about either spelling works. The trouble starts when you take the list out of the library and compare it with text as plain strings, which is what happens the moment you publish a word list or measure coverage against a set.&lt;/p&gt;

&lt;h2&gt;
  
  
  The symptom
&lt;/h2&gt;

&lt;p&gt;We had a job that measures how much of a book a frequency list covers, and it prints the commonest words the list does not know. For German, the top of that report was:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;weiß
saß
ließ
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are some of the most ordinary verbs in the language. If you read the report without thinking, you conclude that frequency lists miss basic German. That is a bug of ours reported as a fact about the language.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why you can't just put the ß back
&lt;/h2&gt;

&lt;p&gt;The tempting fix is to restore the letter in the list. That can't work, because the fold is lossy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;tokenize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;in Maßen, in Massen&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;de&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;in&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;massen&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;in&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;massen&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"In Maßen" means in moderation and "in Massen" means in huge quantities. After the fold they are one token, and nothing in the list tells you which one you are holding. The information is gone before you get the data.&lt;/p&gt;

&lt;p&gt;So we left the list alone and fold the other side at the moment of comparison:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;_MATCH_FOLD&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;de&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ß&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ss&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ru&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ё&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;е&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;uk&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ё&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;е&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fold&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lang&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_MATCH_FOLD&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lang&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;word&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The comparison key changes and the text you show people does not.&lt;/p&gt;

&lt;h2&gt;
  
  
  Russian is the same bug in a softer form
&lt;/h2&gt;

&lt;p&gt;Russian print usually drops the dots on ё, and the corpus has both spellings as separate entries, with very different weights:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;word_frequency&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ещё&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ru&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nf"&gt;word_frequency&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;еще&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ru&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.000513&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.00195&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nothing is missing here, but a book that prints ё gets matched against the rarer entry, and your numbers shift by a factor of about four for one of the commonest words in the language.&lt;/p&gt;

&lt;h2&gt;
  
  
  Turkish breaks plain lower()
&lt;/h2&gt;

&lt;p&gt;While we were in there, we checked the other side of the comparison, our own lowercasing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;KIZ&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;kiz&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;tokenize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;KIZ&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;tr&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;kız&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python's &lt;code&gt;str.lower()&lt;/code&gt; doesn't know the language, so the Turkish capital I becomes the wrong letter. &lt;code&gt;kiz&lt;/code&gt; is not the word at all. The library gets it right, so a homemade tokenizer in front of it quietly disagrees with it. Our fix is two replacements before lowering:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;lang&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;tr&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;İ&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;i&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;I&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ı&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;̇&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What we'd do from the start
&lt;/h2&gt;

&lt;p&gt;Three habits would have caught all of this earlier:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Print the commonest misses, not just the coverage number.&lt;/strong&gt; A coverage of 94% looks fine whether or not it is wrong. A list of misses starting with &lt;code&gt;weiß&lt;/code&gt; does not.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Treat normalisation as part of the data's schema.&lt;/strong&gt; Write down what the source folds, per language, and apply the same fold to anything you compare with it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep two strings.&lt;/strong&gt; A comparison key and a display form are different things, and one field can't be both.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you want the longer version of what these lists leave out, once the spelling is sorted, we wrote it up here: &lt;a href="https://lingvoberry.com/blog/words-a-frequency-list-misses?l=3paddk" rel="noopener noreferrer"&gt;what a frequency list misses&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This article was written with the help of AI. The code comes from our own pipeline, and every output above was run against wordfreq 3.1.1 before publishing.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>analytics</category>
      <category>data</category>
      <category>programming</category>
      <category>python</category>
    </item>
  </channel>
</rss>
