This repository contains code and data for:
Khishigsuren, Regier, Vylomova and Kemp, A computational analysis of lexical elaboration across languages
This folder contains all of our analysis code.
This folder contains processed dictionary data along with other interim outputs needed for preprocessing and analyses.
This folder contains downloaded data needed for preprocessing and analyses, and manually created data needed for our analyses.
Figures, tables and results files generated by the analysis scripts.
Code for preparing the data.
We do not provide pdf versions of non-HathiTrust dictionaries in this repository due to copyright issues. They need to be downloaded from the sources mentioned in rawdata/manuallycreated/nonhathi_dictionaries.csv and put in the folder rawdata/downloaded/nonhathi_raw to reproduce the BILA data set. We used ABBYY FineReader to implement OCR for a number of non-HathiTrust dictionaries (refer to the column ocr in nonhathi_dictionaries.csv) and produced .docx files, which were then used to compile counts for these dictionaries.
Large files not uploaded to this repository need to be downloaded from Zenodo. This folder contains the following files.
-
data_biladataset: includes BILA data set files, which are generated by preprocessing steps described in/preprocessing/README.md. -
output_results: includeshierarchical_lr_lang.csvandhierarchical_lr_dict.csv, results from running hierarchical model on the entire data set, which are generated by runningcompute_zetas_par.Rinanalysisfolder. -
preprocessing_hathi_trust: includeshathi_full_20231101.txt, which contains metadata for all volumes downloaded from HathiTrust in late 2023. If needed, recent versions of this file are available here. The folder also containsef_filelisting.txt, which includes volume ids and can be downloaded usingrsync -azv data.analytics.hathitrust.org::features-2020.03/listing/file_listing.txt . -
rawdata_downloaded: includes a cognate data setCogNet-v2.0.tsvand a Wiktionary dump fileenwiktionary-20240320-pages-articles-multistream, which are used for Wiktionary-based filtering. If needed, the cognate data set is available here and the Wiktionary dump file here. It also includes the foldercru_4.07which contains climate data downloaded from here.
Files must be put in the correct folder in order to reproduce the BILA data set and results from analyses. BILA data set files should be put in data/biladataset, results from hierarchical model in output/results, HathiTrust file in preprocessing/hathi_trust, and the cognate, Wiktionary, and the climate data files in rawdata/downloaded folder.
From within R, run
> renv::restore()
to install packages used by the code in this repository
This code was developed using Python 3.11. See environment.yml for a full specification of the environment used.
A. Assemble the set of dictionaries from HathiTrust (see ../preprocessing/hathi_trust/README.md).
-
Run first
python read_glottolog_language_names.py > ../../data/forpreprocessing/glottolog_variant_names.tsvand thenmake_language_re.Rto collect language names and alternative names from Glottolog. -
Run
python read_hathi_list.py > ../../preprocessing/hathi_trust/01_initial_volumes.csvto extract all candidate volumes with "ictionar" in the title that also met some other conditions described in../preprocessing/hathi_trust/README.md. -
Run
filtered_to_gcode.Rto produce guesses about the correct glottocode and language name to all candidate volumes. -
Make a manual pass through all candidate volumes to mark volumes to be deleted, following the guideline described in
../preprocessing/hathi_trust/README.md. Otherwise, use our manually-edited version of the file02_with_gcodes_manual.csv. -
Run
gcode_to_final_hathilist.Rto drop volumes marked for deletion and to produce the final list of volumes. -
Convert the IDs of all volumes in the final list using
htid2rsync --from-file 02_hathi_ids.txt > 02_hathi_ids_sanitized.txt, wherehtid2rsyncis a command line utility installed as part of the htrc-feature-reader package. -
Download counts for all volumes in the final list using
rsync -av --no-relative --files-from 02_hathi_ids_sanitized.txt data.analytics.hathitrust.org::features-2020.03/ ../../rawdata/downloaded/hathi_raw/. Change the path as needed.
B. Assemble unigram frequencies (see ../preprocessing/README.md). Steps 3 through 8 assemble counts for nouns, verbs and adjectives -- the same steps should be repeated using --pos noun to assemble counts for nouns alone.
-
First run
python readcoca.pyto create POS tags and COCA frequencies. -
Run
make_whitelist.Randpython add_pos_to_whitelist.pyto make a whitelist of words relevant to the analysis of existing claims and case studies. -
Run
find ../rawdata/downloaded/hathi_raw/*.json.bz2| parallel --eta --jobs 90% -n 50 python read_ht_file.py --phase 1 --pos nounverbadjto go through all dictionaries and keep the most frequent 1500 English forms ("Phase 1 vocabulary") in each dictionary that have noun, verb or adj as their most common POS tag according to COCA. Note thatparallelis a UNIX command-line utility. -
Run
python make_vocab.py --pos nounverbadj ../data/forpreprocessing/nounverbadj_counts_phase1/*.csvto assemble the complete set of forms recorded during Phase 1, and add UK variant spellings for all forms and forms from the whitelist. -
Run
find ../rawdata/downloaded/hathi_raw/*.json.bz2| parallel --eta --jobs 90% -n 50 python read_ht_file.py --phase 2 --pos nounverbadjgo through the dictionaries again, and keep counts for all forms belonging to the Phase 1 vocabulary. -
To process non-HathiTrust dictionaries, keeping counts for all forms belonging to the Hathi-derived Phase 1 vocabulary, run the code below:
find ../rawdata/downloaded/nonhathi_raw/*.pdf | parallel --eta --jobs 90% -n 50 python read_nonht_file.py --pos nounverbadjfind ../rawdata/downloaded/nonhathi_raw/*.csv | parallel --eta --jobs 90% -n 50 python read_nonht_file.py --pos nounverbadjfind ../rawdata/downloaded/nonhathi_raw/*.docx | parallel --eta --jobs 90% -n 50 python read_nonht_file.py --pos nounverbadj
-
Run
python collate_dics.py --pos nounverbadjto combine counts for all dictionaries into a single data frame. -
Run
Rscript combine_volumes.R nounverbadjto combine counts across multiple volumes of the same dictionary. -
Run
wiktionary_extract.ipynband thenwiktionary_filter.Rto perform Wiktionary-based filtering. Thewiktionary_extract.ipynbhas the option to set the filtering type as original or updated. The original refers to the Wiktionary-filtering described in the paper and was used to produce all results reported in the paper. The updated method incorporates some improvements that were implemented after the paper was published. Those improvements were reflected in the app that accompanies the Conversation piece, but not the main app. -
Run
wordnet_extract.ipynbin../preprocessing/wordnetto extract information about number of senses from WordNet. -
Run
read_subsistence.Rin../preprocessing/subsistenceto extract subsistence information. -
Run
create_bila_dictionaries.Rto create a master file. -
Run
standardize_bila.Rto create a standard version and a lemmatized version of the dataset.
To reproduce tables and figures in main text and supplementary materials, follow the steps below. All code is in the folder ../analysis. Certain code chunks are set up in a way that prevents from execution when you click "Run All" because it takes several hours to finish running those chunks.
-
Run
read_cru2.Randread_cru_ts4.07.Rin../analysis/environmentto extract temperature and precipitation information for the locations associated with BILA languages. -
Run
preliminary_steps.Rmdto produce interim outputs necessary for the next steps. -
Run
analyze_claims.Rmdto produce Figure 1 and Figure S5. -
Run
analyze_cases.Rmdto produce Figure 2, Table S3, Table S4, and Figure S7. Note that it takes several hours to generate results for Bayesian analyses. -
Run
bottomup_analysis.Rmdto produce Figure 3, Figure S6, and Table S5. Note that it takes several hours to generate results for exhaustive analyses. -
Run
make_maps.Rto produce Figure S1. -
Run
plot_related_lexemes.Rmdto produce Figure S2 and Table S1. -
Run
compute_zetas_par.Randrelatedtermsforapp.Rmdto produce results used for the main app and interim outputs necessary to runexplore_dicts.R. Note that this takes an hour or so. Code for the app is available in a separate github repository and is archived on Zenodo. -
Run
explore_examples.Rto produce Figure S3. -
Run
explore_dicts.Rto produce Figure S4.
Note: Just before finalizing the proofs, we discovered that the glottocode for the Yup'ik Eskimo Dictionary by Jacobson should be cent2127 instead of cent2128. We therefore changed the language name from "Central Siberian Yupik" to "Central Alaskan Yupik" in Figures 1 and 2. However, all other results in the paper remain based on the original coding (cent2128), as there was not enough time to rerun the analyses before publication.