-
pip install numpy pandas opencc-python-reimplemented -
Unzip
lemma-strong-translations.zip -
Run
python src/meaning_importance.py --inputf <input file> --strong_translation_dir lemma-strong-translations-0.2 --alpha 1 --outf test_saliency.tsv. This will translate word forms and produce output filetest_saliency.tsv. Note that<input file>is a tab separated file (without header) that includes language code (corpus), word form and frequency.--alpha 1sets$\alpha^i_m$ to 1. -
You can add
--do_not_translateflag when comparing usage of same word forms across languages (corpora). This will skip all preprocesses involving translations. -
Supported languages include
code language zh Chinese ko Korean id Indonesian ms Malay en English nl Dutch de German da Danish no Norwegian sv Swedish fi Finnish lt Lithuanian pl Polish ru Russian uk Ukrainian mk Macedonian el Greek ro Romanian it Italian fr French ca Catalan es Spanish pt Portuguese
Revealing keywords are documented in goddard-wierzbicka.csv
Unrevealing keywords are documented in external-keywords.csv
- Results and analysis reported in Section 5 are shown in notebook
word-usage-analysis-V4c.ipynb. Results and analysis reported in Section 6 are shown in notebookword-assoc-analysis-V4c.ipynb. - There are three types of files in
measurements:*_word_importance_score*.txtrecords scores of meaning classes associated with respective language (Equation 1, described in Section 5.1).*_word_saliency*.txtrecords saliency scores of meaning classes, corresponding to Section 5.3.*_word_classification*.txtrecords language classification (rank=1) of meaning classes based on word importance scores above.
lemma-strong-translations.zip include multilingual words (including inflected forms) to English lemma
mappings, readily preprocessed with the steps below. The rules and detailsare described in
Supplementary 1.1 and 1.2.
To get inexact English-French translations by strong translation rules (Supplementary 1.1)
- Download WorldLex Data, unzip the files
- Download fastText aligned word vectors
pip3 install OpenCC nltkpython3 src/strong_translate.py --lang fr --fasttext_emb_dir <aligned vectors directory> --freq_dir <worldlex data directory> --output_dir <output directory>
To gather morphological variants based on strong translations in French (Supplementary 1.2)
- Create directories:
mkdir -p lemmatized mean_lemma_emb lemma-strong-translations - Lemmatize all words:
python3 src/word_lemmatize.py --spacy_model <spacy_model> --lang fr --output_file lemmatized/fr.txt --bsz 2000 --n_process 1 - Mean embeddings for each lemma cluster:
python3 src/mean_fasttext_emb.py --aligned_vectors_dir <vectors directory> --lemma_dir lemmatized --output_dir mean_lemma_emb --lang $language - Translate all morphological variants and store the translations in
lemma-strong-translations:python3 src/lemma_strong_translate.py --lemma_vectors_dir mean_lemma_emb --lemma_dir lemmatized --strong_translations_dir <strong translation directory (from above)> --source_lang en --output_dir lemma-strong-translations --lang fr --aligned_vectors_dir fasttext_emb --source_spacy_model <spacy_model> --sim_thresh 0.2