Skip to main content

A Toolkit for Generating Typological Language Samples Based on the Diversity Value

Project description

makeitsample

License: MIT Python

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 node
  • name: the name of the node
  • parent_id: the id of the parent node
  • type: 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(dir="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

makeitsample-1.0.1.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

makeitsample-1.0.1-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file makeitsample-1.0.1.tar.gz.

File metadata

  • Download URL: makeitsample-1.0.1.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for makeitsample-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b379011bcd893ad71f3a7bc616a6bd701ef75c2e7e87a25ae7853ef16338cbe1
MD5 bf63f076ec060c708e37f29df9e9910e
BLAKE2b-256 6e6987ed71161c0e067ca20e6693677ed205f2cfbc4c14e9c6b4a295e4e2764a

See more details on using hashes here.

File details

Details for the file makeitsample-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: makeitsample-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for makeitsample-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5059ba0e2c61cec0caecf7c0e6009491333772852535e48c543641e63aa60eac
MD5 7c0ffd7ccd4ef8b3ef38f552b594f152
BLAKE2b-256 303e5a14baa83ed2a31e972009cca6eb4e98babf6930b60967e7ea0dd7aeb7ea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page