Giter Site home page Giter Site logo

translit-rnn's Introduction

translit-rnn: Automatic transliteration with LSTM

This is a tool to transliterate inconsistently romanized text. It is tested on Armenian (hy-AM). We invite everyone interested to add more languages. Instructions are below.

Read more in the corresponding blog post.

Before training on the corpus we need to compute the vocabularies by the following command:

python make_vocab.py --language hy-AM

The actual training is initiated by a command like this:

python -u train.py --hdim 1024 --depth 2 --batch_size 200 --seq_len 30 --language hy-AM &> log.txt

--hdim and --depth define biLSTM parameters. --seq_len is the maximum length of a character sequence given to the network. The output will be written in log.txt.

During the training the models are saved in the model folder. The following command will run the test set through the selected model:

python -u test.py --hdim 1024 --depth 2 --model {MODEL} --language hy-AM

The above command expects that the test set contains text in the original language. The next one takes a file with romanized text and prints the transliterated text:

python -u test.py --hdim 1024 --depth 2 --model {MODEL} --language hy-AM --translit_path {FILE_NAME}

Finally, plot_loss.py command will draw the graphs for training and validation losses for the given log file. --ymax puts a limit on y axis.

python plot_loss.py --log log.txt --window 10000 --ymax 3

Preparing the data for a given language

This is what we did for Armenian. Something similar will be needed for the other not-very-different languages.

First, we prepare the corpus.

  1. Download the Wikipedia dump (e.g. https://dumps.wikimedia.org/hywiki/20160901/hywiki-20160901-pages-articles.xml.bz2)
  2. Extract the dump using WikiExtractor
  3. Remove the remaining tags that (strings starting with '<')
  4. Spilt the data three parts (80% - train.txt, 10% - val.txt, 10% - test.txt) and store them in the languages/LANG_CODE/data/ folder

Next we add some language specific configuration files:

  1. Populate the languages/LANG_CODE/transliteration.json file with romanization rules, like this one
  2. Populate the languages/LANG_CODE/long_letters.json file with an array of the multi-symbol letters of the current language (Armenian has ու and two capitalizations of it: Ու and ՈՒ)
  3. Run make_vocab.py to generate the "vocabulary"

translit-rnn's People

Contributors

tigrangalstyan avatar hrayrhar avatar hrant-khachatrian avatar mahnerak avatar otanim avatar

Watchers

James Cloos 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.