Coder Social home page Coder Social logo

tldr-pages / tldr-translation-pairs-gen Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 3.0 146 KB

Generates a structured dataset in various formats derived from tldr-pages.

Home Page: https://opus.nlpl.eu/tldr-pages/corpus/version/tldr-pages

License: MIT License

TypeScript 93.53% JavaScript 6.47%
hacktoberfest tldr tldr-pages parallel-corpus

tldr-translation-pairs-gen's Introduction

tldr-translation-pairs-gen

Matrix chat license

About

A CLI application for parsing tldr pages from the tldr-pages/tldr repository, and producing a dataset that maps the strings across localized pages. The motivation was to provide an additional corpus for OPUS, see What is Opus? for more context.

Installation

You can install the tool by running the following commands:

# Clone the repository
git clone https://github.com/tldr-pages/tldr-translation-pairs-gen.git

# Enter the directory that git created when cloning
cd tldr-translation-pairs-gen

# Install dependencies
npm install

# Build the project
npm run build

# Install the project on your machine
npm install -g .

You should now have tldr-translation-pairs-gen on your path, try the help command to see the available options:

tldr-translation-pairs-gen --help

Usage

One way or another, obtain a copy of the tldr-pages. The easiest way is to use Git:

git clone https://github.com/tldr-pages/tldr.git

Point tldr-translation-pairs-gen to the directory using the --source argument. This will output a file for every combination of languages to the dataset/ directory, with all alignments that can be found between localized pages.

tldr-translation-pairs-gen --source {{path/to/tldr_dir}}

You can also pass the --format argument to specify a different output format. The supported file formats are TMX (Translation Memory eXchange), XML, CSV, and JSON.

tldr-translation-pairs-gen --source {{path/to/tldr_dir}} --format csv

Excluded Strings

When generating the dataset, you'll find that not all strings are included. Due to how the project is structured, and the current translation workflow, there are instances where the order or number of examples differ. This results in the localized pages falling out of sync.

Each example in a page features two strings, the description of the command, and the command itself. To work around the aforementioned issue, we parse each example and use the command as an identifier.

To map strings between languages, we parse all examples, remove tokens between curly braces (i.e. {{path/to/file}}) as they can be internationalized, and then find the pairing example in the page of other languages if it exists.

After removing the content between curly braces, two or more examples in the same page may have the same content because the only difference was the tokens. In these cases, we omit them from the corpus as there's no way to unambiguously determine the translation pair.

Here is a real-world example of the problem: the English version was modified after the French translation was made, so now the pages have fallen out of sync. If we made pairs using the index, we'd create mismatches.

EN FR
- Print the tldr page for a specific command (hint: this is how you got here!):

tldr {{command}}
- Affiche la page tldr d'une commande (indice : c'est comme ça que vous êtes arrivé ici !) :

tldr {{commande}}
- Print the tldr page for a specific subcommand:

tldr {{command}}-{{subcommand}}
- Affiche la page tldr de cd, en forçant la plateforme par défaut :

tldr -p {{android|linux|osx|sunos|windows}} {{cd}}
- Print the tldr page for a command for a specific [p]latform:

tldr {{command}}
- Affiche la page tldr d'une sous-commande :

tldr {{git-checkout}}
- [u]pdate the local cache of tldr pages:

tldr -u
- Met à jour les pages enregistrées localement (si le client supporte la mise en cache) :

tldr -u

What is OPUS?

OPUS is public dataset of translated resources on the web. All translations are derived from freely available and openly licensed sources, so the translations themselves are safe to use with minimal restrictions. These datasets are helpful for a variety of applications such as research and machine learning.

A notable project that uses the OPUS corpuses is LibreTranslate, powered by argos-translate. It's a free, open-source, and self-hostable machine translation API that doesn't depend on third-party services. Now by translating tldr-pages, we're collectively contributing more data to improve open-source machine translations!

tldr-translation-pairs-gen's People

Contributors

dependabot[bot] avatar kbdharun avatar sethfalco avatar waldyrious avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tldr-translation-pairs-gen's Issues

Include translatable tokens in dataset

In commands, tokens can be translated.

We can index and pull out the tokens from each command string, and include those mappings in the output as well.

Example

- Add a new task to the work list:

`todo new {{thing_to_do}} --list {{work}}`
- Aggiungere un nuovo task alla lista delle cose da fare per lavoro:

`todo new {{cose_da_fare}} --list {{lavoro}}`
  • thing_to_do → cose_da_fare
  • work → lavoro

Remove square brackets in command description

Some commands have square brackets in the command description, which is a hint to what argument it's referring too. However, this information isn't helpful when pairing translations. This may be worth removing while building the corpus.

Example

pages/common/am.md

`am start -n {{com.android.settings/.Settings}}`

- Start an activity and pass [d]ata to it:

pages.de/common/am.md

- Starte eine Aktivität und übergib ihr Daten:

`am start -a {{android.intent.action.VIEW}} -d {{tel:123}}`

The resulting dataset then has:

<tu>
  <tuv xml:lang="de">
    <seg>Starte eine Aktivität und übergib ihr Daten </seg>
  </tuv>
  <tuv xml:lang="en">
    <seg>Start an activity and pass [d]ata to it </seg>
  </tuv>
</tu>

Publish builds

We need to publish builds of this somewhere, likely npm so that it's more convenient to use.

Duplicate translation units in output

In the project we have certain lines that are repeated frequently, namely the template text like for alias pages.

We should do something to avoid writing out duplicates. Cases where lines are similar but not the same like "More Info…" is perfectly fine since the link is changing, but cases like the alias pages are just 100% the exact same.

feat: allow multiple export formats in a single process

The --format argument currently only accepts 1 format at a time. In the scenario that we want to produce multiple datasets, this means redundantly processing the files multiple times.

To reduce wasted computation/energy, we should support either multiple formats or an all that processes the files once, but exports in all formats specified.

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.