GithubHelp home page GithubHelp logo

milahu / translate-richtext Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 146 KB

translate rich-text documents between human languages, online or offline

License: MIT License

Python 47.53% JavaScript 48.74% Nix 3.68% Shell 0.05%
argos-translate deepl-translate document-translator google-translate html-translator human-languages offline-translator translation translator translate-html

translate-richtext's Introduction

translate richtext

translate rich-text documents between human languages, online or offline

solve two conflicting goals:

  1. preserve the original structure of the document, including whitespace, newlines, indents
  2. preserve sentences across structure boundaries like <p><b>hello</b> world.</p>

use cases

  • translate text documents: html, epub, odt, docx, pdf, rtf, latex
  • translate video subtitles: srt, vtt

challenges

preserve sentences

sentences may be broken by

  • newlines in the source text
  • markup tags

this is a problem, because when we feed sentence-parts to translators, then the translators will return worse quality than in the case, where we feed full sentences to translators

align similar texts

our solution is using two translations:

  1. a "splitted" translation
  2. a "joined" translation

the "splitted" translation serves as a "sourcemap", it has the correct positions of sentence-parts, but the translation has worse quality, because sentences are broken into sentence-parts.

the "joined" translation provides the translated sentences, with better quality than the "splitted" translation, but the locations of sentence-parts are lost.

currently, we align the two translations with a "character diff":

git diff --word-diff=color --word-diff-regex=. --no-index \
  $(readlink -f translation.joined.txt) \
  $(readlink -f translation.splitted.txt) |
sed -E $'s/\e\[32m.*?\e\[m//g; s/\e\\[[0-9;:]*[a-zA-Z]//g' |
tail -n +6 >translation.aligned.txt

related

similar projects

translate-richtext's People

Contributors

milahu avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.