Skip to main content

[CHaracter Ocr COordination for MUFI iN texts] A simple script to maintain a reasonable training set of HTR/OCR characters

Project description

Choco-Mufin

[CHaracter Ocr COordination for MUFI iN texts]

Tools for normalizing the use of some characters and checking file consistencies. Mainly target at dealing with overly diverse ways to transcribe medieval data (allographetic and graphematic for example) while keeping information such as abbreviation, hence MUFI.

Install

pip install chocomufin

Commands

The workflow is generally the following: you generate a conversion table (chocomufin generate table.csv your-files.xml), then use this table to either control (chocomufin control table.csv your-files.xml) or convert them (chocomufin convert table.csv your-files.xml). Conversion will automatically add a suffix which you can define with --suffix.

Table of conversion

Syntax

A conversion table MUST contain at least a char and a replacement column, SHOULD contain a regex and allow column (with either true or empty values), and MAY contain any additional column.

The columns have the following effect:

  • char is used to match a value in the XML or the text.
  • replacement is used to replace what was found in char.
  • regex, if true, means char and replacement should be parsed as regex.
  • allow, if true, will indicate that replacement should be ignored, and that the value(s) in char are valid.

Any other column should be seen as a comment.

Example

In the following table:

lineno,char,replacement,regex,allow
1,V,U,,
2,[a-ik-uw-zA-IK-UW-Z],,true,true
3,(\S)(\.)(\S),\g<0>\g<1> \g<2>,true,
4,_,,,true
  • Line no. 1 will replace any V into a U;
  • Line no. 2 will allow any character in the range defined: those characters won't be replaced and will be accepted as is.
  • Line no. 3 will replace any dot without spaces around it with a regex replacement groups used in the regex.
  • Line no. 4 will allow _ in the text, and not replace it with anything.

As table:

lineno char replacement regex allow
1 V U
2 [a-ik-uw-zA-IK-UW-Z] true true
3 (\S)(.)(\S) \g<1>\g<2> \g<3> true
4 _ true

In this context, lineno is not used at all by chocomufin, but serves as a documentation tool. It would not break chocomufin.

Github Action Template

Just replace the path to table.csv and the file that needs to be tested, then save this file on your repository in .github/workflows/chocomufin.yml:

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: ChocoMufin

on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Set up Python 3.8
      uses: actions/setup-python@v2
      with:
        python-version: 3.8
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install chocomufin
    - name: Run ChocoMufin
      run: |
        chocomufin control table.csv **/*.xml

Logo by Alix Chagué.

The file original_mufi_json's content is under CC BY-SA 4.0 and comes from https://mufi.info/m.php?p=mufiexport

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chocomufin-1.0.2.tar.gz (46.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chocomufin-1.0.2-py3-none-any.whl (38.7 kB view details)

Uploaded Python 3

File details

Details for the file chocomufin-1.0.2.tar.gz.

File metadata

  • Download URL: chocomufin-1.0.2.tar.gz
  • Upload date:
  • Size: 46.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for chocomufin-1.0.2.tar.gz
Algorithm Hash digest
SHA256 2296614ea44b489b67a7adf0e9a2eec0165cb2b0190bab7cc2321299d8c6f521
MD5 24ca7e0837e191c464d0e42d914ec381
BLAKE2b-256 15f62394ca8703e1b6b1d2112ba92e627fc352b321fb4ffd8cfedcabbdc443af

See more details on using hashes here.

File details

Details for the file chocomufin-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: chocomufin-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 38.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for chocomufin-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1a021b3caf622db4505a8a695e4e9824309ab4eabb48629aacc317a4946d18c9
MD5 8c18170db5650e8df1028acaaaa641b8
BLAKE2b-256 742ad812ca8aaed7c2917eb8237e71279c2e155e3cb014b81ef3d23e10686e3a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page