AI4Bharat-IndicNLP Corpus

repository·master·Indexed 42 days ago

https://github.com/ai4bharat/indicnlp_corpus

Large-scale, general-domain corpora for 12 Indian languages, including pre-trained word embeddings and evaluation datasets for NLP tasks such as classification and word similarity. Provides tools for training word embeddings via FastText and unsupervised morphanalyzers using Morfessor.

Tokens
2.2K
Snippets
7
Records
11
Agent score
3%

What's inside IndicNLP Corpus

  1. Access the IndicNLP Text Corpora

    master

    The IndicNLP project provides large-scale, general-domain text corpora for 12 Indian languages. The corpora are already tokenized using the IndicNLP tokenizer. If you require a detokenized version, you should use the IndicNLP detokenizer.

    Available languages and their corpus links:

  2. Download IndicNLP Morphanalyzers

    master

    IndicNLP Morphanalyzers are unsupervised morphanalyzers trained using morfessor. You can download pre-trained Version 1 models for various Indic languages via the following links:

  3. Train a Morfessor model

    master

    To train a new morphanalyzer, you must first extract a vocabulary from an existing embeddings file and then run the morfessor-train command.

    1. Extract vocabulary from embeddings file

    Use zcat, tail, and cut to isolate the first column (the words) from the embedding vectors file, skipping the header.

    2. Train Morfessor

    Run the morfessor-train command using the extracted vocabulary file as the training data source.

    ## extract vocabulary from embedings file
    zcat $embedding_vectors_path |  \
        tail -n +2 | \
        cut -f 1 -d ' '  > $vocab_file_path
    
    ## train morfessor 
    morfessor-train -d ones \
            -S $model_file_path \
            --logfile  $log_file_path \
            --traindata-list $vocab_file_path \
            --max-epoch 10
  4. Evaluate word embeddings on Word Analogy tasks

    master

    To evaluate embeddings on the Facebook word analogy dataset, you must first add the MUSE root directory to your PYTHONPATH. Then, use the word_analogy.py script.

    export PYTHONPATH=$PYTHONPATH:$MUSE_PATH
    
    python  scripts/word_analogy/word_analogy.py \
        --analogy_fname <analogy_fname> \
        --embeddings_path <embedding_file_path> \
        --lang 'hi' \
        --emb_dim 300 \
        --cuda
  5. Evaluate embeddings on News Article Classification datasets

    master

    The IndicNLP project provides a news article classification dataset for 9 languages (Bengali, Gujarati, Kannada, Malayalam, Marathi, Oriya, Punjabi, Tamil, and Telugu).

    1. Download the dataset: indicnlp-news-articles.tgz
    2. Run evaluation: Use the txtcls.py script with the following arguments:
    • --emb_path: Path to your trained embeddings.
    • --data_dir: Path to the downloaded classification data.
    • --lang: The language code (e.g., 'hi', 'bn').
    python3 scripts/txtcls.py --emb_path <path> --data_dir <path> --lang <lang code>
  6. Evaluate embeddings on Publicly available Classification Datasets

    master

    You can evaluate embeddings on several public datasets (ACTSA, BBC News, IIT Patna Product/Movie Reviews, INLTK Headlines, and Bengali News) using the standard test/validation/test splits provided by AI4Bharat.

    1. Download the splits: classification_public_datasets.tgz
    2. Run evaluation: Use the txtcls.py script.

    Arguments:

    • --emb_path: Path to your trained embeddings.
    • --data_dir: Path to the downloaded public datasets.
    • --lang: The language code.
    python3 scripts/txtcls.py --emb_path <path> --data_dir <path> --lang <lang code>
  7. Train word embeddings using FastText

    master

    You can train word embeddings on the IndicNLP corpora using the FastText skipgram command. Ensure you have the $FASTTEXT_HOME environment variable set and your mono-lingual corpus path defined in $mono_path.

    $FASTTEXT_HOME/build/fasttext skipgram \
    	-epoch 10 -thread 30 -ws 5 -neg 10    -minCount 5 -dim 300 \
    	-input $mono_path \
    	-output $output_emb_prefix 
  8. Cite the IndicNLP Corpus

    master

    If you use any resources from the AI4Bharat-IndicNLP Corpus, please cite the following BibTeX entry:

    @article{kunchukuttan2020indicnlpcorpus,
        title={AI4Bharat-IndicNLP Corpus: Monolingual Corpora and Word Embeddings for Indic Languages},
        author={Anoop Kunchukuttan and Divyanshu Kakwani and Satish Golla and Gokul N.C. and Avik Bhattacharyya and Mitesh M. Khapra and Pratyush Kumar},
        year={2020},
        journal={arXiv preprint arXiv:2005.00085},
    }
    @article{kunchukuttan2020indicnlpcorpus,
        title={AI4Bharat-IndicNLP Corpus: Monolingual Corpora and Word Embeddings for Indic Languages},
        author={Anoop Kunchukuttan and Divyanshu Kakwani and Satish Golla and Gokul N.C. and Avik Bhattacharyya and Mitesh M. Khapra and Pratyush Kumar},
        year={2020},
        journal={arXiv preprint arXiv:2005.00085},
    }