A Toolkit for Generating Typological Language Samples Based on the Diversity Value
Project description
makeitsample is a Python library for generating typological language samples using the diversity value (DV) metric (Rijkhoff et al., 1993; Rijkhoff and Bakker, 1998; Bakker, 2010).
It provides tools to build language family trees from CSV data, compute diversity values for each node, and select a representative set of languages that reflect genealogical and typological diversity.
📚 What It Does
makeitsample is designed to support researchers and linguists in the creation of typologically diverse language samples. It consists of two main modules:
language_family_tree.py— defines tree structures and computes diversity values (DV).forest.py— manages a forest of language families and handles sampling logic across multiple trees.
🚀 Features
- Build hierarchical language family trees from CSV input.
- Handle both nested genealogies and isolated languages.
- Calculate diversity values at each node in a tree.
- Select representative languages based on weighted sampling.
- Minimal dependencies and easy integration into other projects.
📦 Installation
pip install makeitsample
🛠️ Usage
Prepare the input files
makeitsample requires a set of input files (representing language families) in CSV format. The CSV files should contain the following columns:
id: the id of the nodename: the name of the nodeparent_id: the id of the parent nodetype: the type of the node (the only allowed values are "family", "group" or "language")
The user can also add any other columns to the CSV files.
As a library
Create a language family tree from CSV data
import makeitsample.language_family_tree as lft
# Create a language family tree from CSV data
family = lft.LanguageFamilyTree("path/to/csv/file.csv")
# Print the tree structure
print(family)
Calculate diversity values for the language family trees
from makeitsample.forest import Forest
# Create a forest of language families
language_families = Forest("path/to/directory/with/csv/files")
# Update the trees with diversity values
language_families.dv()
# Export the updated trees to CSV
language_families.export_forest(dir="path/to/output/dir", format="csv")
Sample languages from the language family trees
from makeitsample.forest import Forest
# Create a forest of language families
language_families = Forest("path/to/directory/with/csv/files")
# Sample languages from the forest
language_families.make_sample(n=100)
# Export the sampled languages to CSV
language_families.export_sample(dir="path/to/output/dir", format="csv")
# Export the sampled languages to JSON
language_families.export_sample(dir="path/to/output/dir", format="json")
As a command-line tool
Sample languages from the language family trees
makeitsample [-h] [-n N] [-i INPUT] [-o OUTPUT] [-f {csv,json}] [-s SAMPLENAME] [-r RANDOM_SEED]
Arguments
-h,--help: Show this help message and exit.-n N,--number N: Number of languages to sample.-i INPUT,--input INPUT: Path to the input directory containing CSV files.-o OUTPUT,--output OUTPUT: Path to the output directory for sampled languages.-f {csv,json},--format {csv,json}: Output format for sampled languages (default: csv).-s SAMPLENAME,--sample_name SAMPLENAME: Name of the sample (default: sample).-r RANDOM_SEED,--random_seed RANDOM_SEED: Random seed for reproducibility.
Example usage
makeitsample -n 100 -i data -o out -f csv -s test_sample
📄 License
This project is licensed under the MIT License. See the LICENSE file for details.
📄 Citation
If you use this library in your research, please cite the following paper:
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file makeitsample-0.0.2.tar.gz.
File metadata
- Download URL: makeitsample-0.0.2.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4671c0a62bccb4252557c94817c3d9f17b989d77e12e9e97d7ec07e9644f2d16
|
|
| MD5 |
3195638964d1ae53841c4f1a9c2a5267
|
|
| BLAKE2b-256 |
aaf2ce2ebc430ad434ccd73c63b70cbfffc04c637e837f6c77bade871f93260e
|
File details
Details for the file makeitsample-0.0.2-py3-none-any.whl.
File metadata
- Download URL: makeitsample-0.0.2-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64fb9c8838220d1945344da5a8822a48a36da855825c4f22c20ebe3624d4a446
|
|
| MD5 |
3a9de077b9e4a91db1bd6f7350406f7f
|
|
| BLAKE2b-256 |
113a5f4561bac0af319f8f9a01bd02bbc172055a45d1304073433a6afd86e70a
|