GithubHelp home page GithubHelp logo

marcobarb94 / gtexfix Goto Github PK

View Code? Open in Web Editor NEW

This project forked from drgulevich/gtexfix

0.0 0.0 0.0 60 KB

Fix for Google Translate to process LaTeX documents.

License: GNU General Public License v3.0

Python 100.00%

gtexfix's Introduction

gtexfix

Fix for Google Translate to process LaTeX documents. Updated to simplify some steps.

Description

Code step1.py replaces the LaTeX constructs by tokens. After passing translation the tokens are then restored by step2.py. Simple tokens of the type [number.number] are used, which are more friendly to Google Translate (or DeepL). If the token type conflicts with the original text the user is notified. At times, Google Translate will corrupt the tokens and may even change their numbers unpreditably (the side effect of machine learning!). Corrupted tokens are identified and reported to the user for manual treatment.

Usage

  1. Run $./step1.py path/source.tex to produce path/source_XX.txt, where XX is 00,01,.... Several files are produced if the output exceeds the Google Translate character limit (actual: 5000). If you need only one file, pass -i as optional parameter (e.g. $./step1.py -i path/source.tex).

  2. Feed files <source_*.txt> to Google Translate or DeepL. I suggest to use DeepL desktop app to speed up the work.

  3. Run $./step2.py <source> to produce <sourceT9N.tex>. It looks in your folder to find all files that start like source_. This code removes the italian advertisement message of DeepL too (for now).

  4. Check for the corrupted tokens. You should be able to substitute them manually by looking at gtexfix_commands.json.

Example

Sample LaTeX input is give in the examples folder.

Step 1. Run python step1.py examples/example:

$ python step1.py examples/example
LaTeX file: examples\example.tex
No token conflicts detected. Proceeding.
Output file: examples\example_00.txt
Output file: examples\example_01.txt
Output file: examples\example_02.txt
Supply the output file(s) to Google Translate

Step 2. Google Translate or DeepL.

Step 3. Run python step2.py examples/example:

$ python step2.py examples/example
Input file (original): examples/example
I found these files:
['examples\\example_00.txt', 'examples\\example_01.txt', 'examples\\example_02.txt']
Backup file not found
Output file: examples/exampleT9N.tex
No corrupted tokens. The translation is ready.

Step 4.

gtexfix's People

Contributors

drgulevich avatar marcobarb94 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.