Aksharamukha Script Converter

repository·master·Indexed 42 days ago

https://github.com/virtualvinodh/aksharamukha

A comprehensive transliteration engine for script conversion within the Indic cultural sphere, supporting over 120 scripts and various romanization methods. It provides a REST API for text, XML, HTML, and DOCX conversion, along with tools for script auto-detection, syllabary retrieval, and conjunct mapping. The system can be deployed via Docker Compose with a Quasar/Vue frontend and a Python/Flask backend.

Tokens
2.8K
Snippets
14
Records
17
Agent score
51%

What's inside Aksharamukha

  1. Run Aksharamukha locally using Docker

    master

    The easiest way to run the full Aksharamukha stack (frontend, backend, and local font server) is via Docker Compose. This orchestrates all necessary containers and binds the web application to http://localhost:12345.

    # Inside the project's root folder
    docker compose up
  2. Set up the Aksharamukha Frontend (Quasar/Vue)

    master

    The frontend is built with Quasar and Vue. To run it manually, follow these steps:

    1. Install Node.js: Use a version supported by Quasar (v14 LTS is recommended).
    2. Install Quasar CLI: npm install -g @quasar/cli.
    3. Configure quasar.conf.js: Comment out line 9 to disable the analytics plugin, which prevents build failures.
    4. Configure API Key: In src/pages/index.vue, comment out import keys from '../keys.js' and add an empty keys object to bypass Google's OCR API requirement:
    // sets empty API key for Google's OCR API to build the project without using that service
    var keys = {}
    keys['api_key'] = ''
    1. Set API Endpoint: Ensure the API points to localhost in mixins/ScriptMixin.js.
    2. Start Development Server: Run quasar dev and navigate to the address provided in the terminal output.
    npm install
    # ... follow configuration steps above ...
    quasar dev
  3. Deploy Aksharamukha using Docker Compose

    master

    You can deploy the full Aksharamukha stack (Frontend, Backend, and Fonts) using Docker Compose. This setup orchestrates three distinct services, each exposing specific ports on the host machine.

    Services and Port Mappings

    ServiceImageHost PortContainer Port
    front (Frontend)virtualvinodh/aksharamukha-front1234580
    back (Backend)virtualvinodh/aksharamukha-back80858085
    fonts (Fonts)virtualvinodh/aksharamukha-fonts989980

    To run the stack, ensure you have a docker-compose.yaml file with the following configuration and execute docker-compose up.

    version: '3'
    services:
      front:
        image: virtualvinodh/aksharamukha-front
        ports:
          - "12345:80"
      back:
        image: virtualvinodh/aksharamukha-back
        ports:
          - "8085:8085"
      fonts:
        image: virtualvinodh/aksharamukha-fonts
        ports:
          - "9899:80"
  4. Explore Aksharamukha JSON Resources

    master

    The project provides several JSON-based data resources located in aksharamukha-back/resources for script mappings, matrices, and syllabaries:

    • Script Mapping: Found in script_mapping/. Characters with approximate mappings to the generic Indic scheme are marked with ʽ (U+02BD). You may need to strip this character during post-processing.
    • Script Matrix: Found in script_matrix/. Filenames indicate the guiding romanization and chunk size (e.g., script_matrix_IAST5.json uses IAST and chunks of 5).
    • Syllabaries: Found in syllabary/. Contains lists of vowels, consonants, and consonant-vowel compounds for each script.
    • Sanskrit/Pali Conjuncts: Found in conjuncts1/ and conjuncts2/. Files are split by the number of consonants and include a suffix for the appended vowel (e.g., conjuncts_Gujarati_o.json contains Gujarati conjuncts with the vowel /o/).
  5. Convert DOCX files

    master

    The /api/convert_docx endpoint handles DOCX files. It expects the input text to be a comma-separated string where the first part is a Base64 encoded version of the file content.

    Request Body (JSON):

    • source: Source script.
    • target: Target script.
    • text: A string in the format [base64_encoded_content],[file_part_identifier].
    • nativize: Boolean.
    • preOptions: List of strings.
    • postOptions: List of strings.

    Response:

    • A JSON string containing the converted file in the format [base64_encoded_content],[file_part_identifier].
    POST /api/convert_docx
    {
      "source": "Devanagari",
      "target": "Latin",
      "text": "base64_data,file_id",
      "nativize": true,
      "preOptions": [],
      "postOptions": []
    }
  6. Convert HTML content

    master

    The /api/convert_html endpoint uses transliterate_file.convert_html to process HTML strings, preserving the structure while converting the text content.

    Request Body (JSON):

    • source: Source script.
    • target: Target script.
    • text: The HTML string.
    • nativize: Boolean.
    • preOptions: List of strings.
    • postOptions: List of strings.

    Response:

    • A JSON string containing the converted HTML.
    POST /api/convert_html
    {
      "source": "Devanagari",
      "target": "Latin",
      "text": "<p>नमस्ते</p>",
      "nativize": true,
      "preOptions": [],
      "postOptions": []
    }
  7. Retrieve conjuncts for a script

    master

    The /api/conjuncts endpoint returns lists of conjunct characters for a specific script and vowel.

    Request Body (JSON):

    • script1: The source script.
    • script2: The target script.
    • vowel: The vowel to associate with the conjuncts.
    • postoptions: List of post-processing options.

    Response:

    • A JSON object containing multiple levels of conjuncts (e.g., conjuncts1S1, conjuncts1S2, etc.) representing different complexity levels or groupings.
    POST /api/conjuncts
    {
      "script1": "Devanagari",
      "script2": "Latin",
      "vowel": "a",
      "postoptions": []
    }
  8. Detect pre-processing options for a script

    master

    Use the /api/detectpre endpoint to find appropriate pre-processing options for a specific script and text. This helps in preparing text for accurate transliteration.

    Request Body (JSON):

    • text: The text to analyze.
    • source: The detected or known source script name.

    Response:

    • A JSON object containing recommended pre-processing options.
    POST /api/detectpre
    {
      "text": "your text here",
      "source": "Tamil"
    }
  9. Convert text between scripts

    master

    The core functionality of the API is provided via the /api/convert endpoint. It allows transliterating text from a source script to a target script with optional pre/post-processing and nativization.

    Request Body (JSON):

    • source: The source script name.
    • target: The target script name.
    • text: The text to be converted.
    • nativize: Boolean (true/false) to determine if the output should be nativized.
    • preOptions: List of strings representing pre-processing steps.
    • postOptions: List of strings representing post-processing steps.

    Response:

    • The converted text (newlines are replaced with <br/>).
    POST /api/convert
    {
      "source": "Devanagari",
      "target": "Latin",
      "text": "नमस्ते",
      "nativize": true,
      "preOptions": [],
      "postOptions": []
    }