<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged text-analysis</title>
<link>https://coderlegion.com/tag/text-analysis</link>
<description>Powered by Question2Answer</description>
<item>
<title>Open-Source Python Tools for Russian Text Processing in Digital Humanities</title>
<link>https://coderlegion.com/25025/open-source-python-tools-for-russian-text-processing-in-digital-humanities</link>
<description>&lt;p&gt;&lt;em&gt;Practical tools for OCR, accentuation, and text analysis that every developer should know about&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;the-problem&quot;&gt;The Problem&lt;/h3&gt;
&lt;p&gt;If you're working with Russian texts in the humanities, you've probably faced this situation: you need to process a pre-1917 text, but every NLP tool is trained on modern Russian. Or you want to analyze verse, but stress marks are missing. Or you have a TEI XML document that needs conversion, but existing tools are either proprietary or dead.&lt;/p&gt;
&lt;p&gt;While large language models are everywhere, they're surprisingly bad at these specific tasks. As Orekhov (2025) points out in his review, &quot;modern versions of artificial intelligence cannot handle subtle nuances tied to specific subject domains.&quot;&lt;/p&gt;
&lt;p&gt;Worse, even when good solutions exist, nobody knows about them. Orekhov mentions at least two separate attempts to rebuild functionality that was already available in open-source Python packages — a clear sign that the real problem isn't technical, but informational.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;what-s-actually-available&quot;&gt;What's Actually Available&lt;/h3&gt;
&lt;p&gt;Here are the tools Orekhov covers. All are open-source, Python-based, and created by researchers at HSE University's School of Linguistics.&lt;/p&gt;
&lt;h4 id=&quot;1-pre-1917-russian-orthography-support&quot;&gt;1. Pre-1917 Russian Orthography Support&lt;/h4&gt;
&lt;h5 id=&quot;ocr-model-for-old-orthography&quot;&gt;OCR Model for Old Orthography&lt;/h5&gt;
&lt;p&gt;&lt;strong&gt;Repository&lt;/strong&gt;: &lt;a rel=&quot;nofollow&quot; href=&quot;https://huggingface.co/Serovvans/trocr-preferform-orthography&quot;&gt;Serovvans/trocr-preferform-orthography&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The model uses Tesseract-OCR infrastructure and handles the pre-reform Russian alphabet (including Ѣ, Ѳ, Ѵ, and the final Ъ). It's actually trained on modern Russian text in old orthography (not Old Church Slavonic — the model's description incorrectly labels it as &quot;Old Russian&quot;).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Quality metrics&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;CER (Character Error Rate): 0.095&lt;/li&gt;
&lt;li&gt;WER (Word Error Rate): 0.298&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This means only about 70% of words are correctly recognized. Not great, but it's free and works well enough when combined with GPT-4 for correction, as Orekhov demonstrates with an example where GPT-4o successfully cleans up OCR errors while preserving the old orthography.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example usage&lt;/strong&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from recognize_page import recognize_page

page_path = &quot;page.png&quot;
text = recognize_page(page_path, text_output_path=&quot;output/file.txt&quot;)
print(f&quot;Text from page:\n{text}&quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Dependencies&lt;/strong&gt;: tesseract-ocr, poppler, pytesseract, Pillow, transformers, torch, numpy, tqdm, pdf2image&lt;/p&gt;
&lt;p&gt;⚠️ &lt;strong&gt;Note&lt;/strong&gt;: For 18th-century texts with that weird 'm'-shaped 'т', this model doesn't work well. You'll need proprietary Transkribus models (which Orekhov warns against due to their dependence on a private company with an uncertain future).&lt;/p&gt;
&lt;h5 id=&quot;old-to-new-orthography-converter&quot;&gt;Old to New Orthography Converter&lt;/h5&gt;
&lt;p&gt;&lt;strong&gt;Repository&lt;/strong&gt;: &lt;a rel=&quot;nofollow&quot; href=&quot;https://pypi.org/project/preferom2modern/&quot;&gt;preferom2modern on PyPI&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Simple, dependency-free string conversion. Can output plain text or TEI XML with &lt;code&gt;&amp;lt;choice&amp;gt;&lt;/code&gt; tags preserving both versions:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-xml&quot;&gt;&amp;lt;choice&amp;gt;
  &amp;lt;reg&amp;gt;пример&amp;lt;/reg&amp;gt;
  &amp;lt;orig&amp;gt;примѣръ&amp;lt;/orig&amp;gt;
&amp;lt;/choice&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Works from both command line and Python. Orekhov notes it's been unmaintained for years, but that's actually fine — it worked correctly from day one.&lt;/p&gt;
&lt;hr&gt;
&lt;h4 id=&quot;2-literary-and-poetic-text-analysis&quot;&gt;2. Literary and Poetic Text Analysis&lt;/h4&gt;
&lt;h5 id=&quot;accentuation-module-for-russian-verse&quot;&gt;Accentuation Module for Russian Verse&lt;/h5&gt;
&lt;p&gt;&lt;strong&gt;Repository&lt;/strong&gt;: &lt;a rel=&quot;nofollow&quot; href=&quot;https://pypi.org/project/ru-accent-poet/&quot;&gt;ru-accent-poet on PyPI&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This is a hybrid approach: dictionary-based + recurrent neural network. It's designed specifically for poetic texts where stress placement is crucial for meter analysis.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Performance&lt;/strong&gt;: The main downside is speed. A pre-annotated dataset of classical Russian prose was published in 2024 to let researchers skip the processing step.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Citation&lt;/strong&gt;: Короткова Ю. О. (2022). Комбинированный словарно-нейросетевой акцентуатор для разметки русского поэтического текста. &lt;em&gt;Труды Института русского языка им. В. В. Виноградова&lt;/em&gt;, 3(33), 181–190.&lt;/p&gt;
&lt;h5 id=&quot;direct-speech-detector&quot;&gt;Direct Speech Detector&lt;/h5&gt;
&lt;p&gt;&lt;strong&gt;Repository&lt;/strong&gt;: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/neiriz/direct-speech-detector&quot;&gt;neiriz/direct-speech-detector&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This isn't just a rule-based approach — it's a full pipeline combining regex (for direct speech marks) with morphological parsing, parsing, and text segmentation. It handles cases where direct speech and authorial narration are mixed.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Use cases&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Comparing dialogue density across novels (there's previous work by Sobchuk, 2016)&lt;/li&gt;
&lt;li&gt;Analyzing character speech patterns&lt;/li&gt;
&lt;li&gt;Extracting dialogue for stylistic analysis&lt;/li&gt;
&lt;/ul&gt;
&lt;h5 id=&quot;formulaicity-assessment-module&quot;&gt;Formulaicity Assessment Module&lt;/h5&gt;
&lt;p&gt;&lt;strong&gt;Repository&lt;/strong&gt;: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/evgenilatyshev/formulaicity&quot;&gt;evgenilatyshev/formulaicity&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This is for folklore studies. It detects formulaic expressions — repeated phrases characteristic of oral traditions. The algorithm combines:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Vocabulary variability coefficient (VocD)&lt;/li&gt;
&lt;li&gt;N-gram coefficients&lt;/li&gt;
&lt;li&gt;Binomial expressions&lt;/li&gt;
&lt;li&gt;Fixed phrases&lt;/li&gt;
&lt;li&gt;Interjections&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Example output&lt;/strong&gt; (from a folk song analyzed by the module's author, V. Sidnenko):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Found n-grams: 
- черный ворон

Formulaicity coefficient: 1.207
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Dependencies&lt;/strong&gt;: spacy, pymorphy2, numpy, sklearn&lt;/p&gt;
&lt;h5 id=&quot;tei-xml-converter&quot;&gt;TEI XML Converter&lt;/h5&gt;
&lt;p&gt;&lt;strong&gt;Repository&lt;/strong&gt;: &lt;a rel=&quot;nofollow&quot; href=&quot;https://pypi.org/project/TEItransformer/&quot;&gt;TEItransformer on PyPI&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;TEI is the standard XML format for digital humanities. This module, developed by Kostyanitsyna and Skorinkin (2024), converts TEI XML to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;DOCX&lt;/strong&gt; (editable format)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;HTML&lt;/strong&gt; (with search functionality)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;JSON&lt;/strong&gt; (for data analysis)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Under the hood, it's actually an XSLT wrapper — which Orekhov candidly calls an &quot;outdated and unreliable technology&quot; for XML processing, but acknowledges that building a pure Python alternative proved too complex.&lt;/p&gt;
&lt;p&gt;The generated HTML includes a search interface that lets you query by character, speaker, or any TEI-annotated field.&lt;/p&gt;
&lt;hr&gt;
&lt;h4 id=&quot;3-journal-publication-preprocessing&quot;&gt;3. Journal Publication Preprocessing&lt;/h4&gt;
&lt;h5 id=&quot;cgi-processor&quot;&gt;cgi-processor&lt;/h5&gt;
&lt;p&gt;&lt;strong&gt;Repository&lt;/strong&gt;: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/nevmenandr/cgi_processor&quot;&gt;nevmenandr/cgi_processor&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This is a niche tool for the journal &quot;Цифровые гуманитарные исследования&quot; (Digital Humanities Research). It handles LaTeX preprocessing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Non-breaking spaces between initials and surnames&lt;/li&gt;
&lt;li&gt;Em-dashes in number ranges&lt;/li&gt;
&lt;li&gt;Other typographic rules specific to Russian academic publishing&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The journal uses LaTeX for production, and manual typographic cleanup is error-prone. This automates it, saving editors from the tedious process of manually inserting special characters.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;why-this-matters&quot;&gt;Why This Matters&lt;/h3&gt;
&lt;p&gt;Here's the thing: these tools solve real problems that LLMs can't handle well. They're infrastructure. They're the kind of boring, practical code that enables interesting research.&lt;/p&gt;
&lt;p&gt;The bigger issue, as Orekhov emphasizes, is visibility. Researchers often don't even check if their problem has already been solved. There's a mental block: &quot;my problem is so specific, surely nobody else has built this.&quot;&lt;/p&gt;
&lt;p&gt;But they have. And it's open source.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;reference&quot;&gt;Reference&lt;/h3&gt;
&lt;p&gt;Orekhov, B. V. (2025). Otkrytye komp'yuternye instrumenty dlya resheniya zadach otsifrovki i analiza russkoyazychnogo teksta v oblasti Digital Humanities [Open computer tools for digitization and analysis of Russian-language text in Digital Humanities]. &lt;em&gt;Tsifrovye gumanitarnye issledovaniya&lt;/em&gt;, (2), 71–83. DOI: &lt;a rel=&quot;nofollow&quot; href=&quot;https://doi.org/10.31860/cgi-2025-2-71-83&quot;&gt;10.31860/cgi-2025-2-71-83&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Available (in Russian) at: &lt;a rel=&quot;nofollow&quot; href=&quot;https://nevmenandr.github.io/portfolio/assets/pdf/cgi2025-2-tools.pdf&quot;&gt;https://nevmenandr.github.io/portfolio/assets/pdf/cgi2025-2-tools.pdf&lt;/a&gt;&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/25025/open-source-python-tools-for-russian-text-processing-in-digital-humanities</guid>
<pubDate>Tue, 15 Sep 2026 08:52:00 +0000</pubDate>
</item>
</channel>
</rss>