Skip to content

cshnican/spatial_demonstratives

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

title spatial_demonstratives
author Sihan Chen, Richard Futrell, Kyle Mahowald
date July 6 2023

An information-theoretic approach to the typology of spatial demonstratives


Folders

  • figures: all the figures in the paper (Figures 1-8)

  • sheets: all data files generated by the scripts

  • readable_data_tables: all the spatial deictic demonstratives complied by Nintemann et al. (2020), as spreadsheets

  • deictic_appendix_docs: the original appendix in Nintemann et al. (2020)

Jupyter notebook

  • Fit_gamma_new.ipynb: the main file. It executes run_ib.py to perform the relevent calculation and generates the data files.

Python

  • run_ib_new.py: the Python script for calculating the informativity and complexity of real lexicons and all possible lexicons, given a number of distal levels, decay parameter $\mu$, and place/goal/source coordinates

  • ib.py: the Python script for the Information Bottleneck (IB) method in general

  • stirling.py: the Python script for calculating the Stirling number of the second kind, given 2 parameters $(n, k)$. Code credit to EXTR3ME.

  • get_prior.py: the Python script for interpolating the prior / need probability $p(m)$ from the Finnish corpus

  • get_lang_data.py: the Python script for processing the data from Nintemann et al. (2020)

  • enumerate_lexicons.py: the Python script for generating all possible lexicons

R

  • Plot Figures.Rmd: the R script for generating the main figures (Experiments 1 and 3)

  • Plot Grid Search.Rmd: the R script for analyzing the grid search data (Experiment 2)

  • plot maps.Rmd: the R script for plotting the maps (Figure 4)

  • Plot Figures_merge_d1d2.Rmd: the R script for the analysis in Appendix E

How to run the files


Experiments 1 and 3:

  1. Launch Fit_gamma.ipynb. Parameters in the model are:
  • logsp: the trade-off parameter array. The default setting np.logspace(3,0, num = 2000) generates 2000 log-spaced tradeoff parameters $\beta$ from 1000 to 1.

  • mu: the decay parameter. The default is 0.2.

  • num_dists: the number of distal levels. The default is 3.

  • pgs_dists: the coordinates of place/goal/source. The default is [0, 0.789, -1.315]

    The script will generate 4 files, saved in the sheets folder:

  • 2 data files for real lexicons and all possible lexicons, respectively.

    • File 1: a data file for real lexicons, syntax: real_lexicons_fit_mu_<mu value>_pgs_<pgs values>num_dists_<number of distal levels>.csv (the default name is real_lexicons_fit_mu_0.2_pgs_0_0.789_-1.315num_dists_3.csv)
    • File 2: a data file for all possible lexicons, syntax: sim_lexicons_fit_mu_<mu value>_pgs_<pgs values>num_dists_<number of distal levels>.csv (the default name is sim_lexicons_fit_mu_0.2_pgs_0_0.789_-1.315num_dists_3.csv)
  • 2 files for the deterministic and non-deterministic optimal frontier, respectively.

    • 1 data file for the deterministic optimal frontier, syntax: ib_curve_deter_mu_<mu value>_pgs_<pgs values>num_dists_<number of distal levels>.csv
    • 1 data file for the non-deterministic optimal frontier, syntax: ib_curve_non_deter_mu_<mu value>_pgs_<pgs values>num_dists_<number of distal levels>.csv
  1. Open and run the plot_figs.Rmd script. Figures will be generated in the figures folder.

Experiment 2:

  1. Open a terminal on the repo, run the lines below, assuming you're following the default condition.
    • Place/goal/source coordinate search: Run the code below (warning: this might take a day to execute. We recommend skipping this step and using our output file.). This will generate a file called total_grid_search_gridsearch.csv in the sheets folder.
python run_ib.py --total_search --outfile sheets/total_grid_search
- Prior search: Run the code below. This will generate a file called ``prior_search_gridsearch.csv`` in the ``sheets`` folder.
python run_ib.py --prior_search --outfile sheets/prior_search
- Mu search: Run the code below. This will generate a file called ``mu_search_gridsearch.csv`` in the ``sheets`` folder.
python run_ib.py --mu_search --outfile sheets/mu_search
  1. Open and run the Plot Grid Search.Rmd script. Figures will be generated in the figures folder.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors