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.2.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.2-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: makeitsample-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 90dee24d91ff43612987e38bb4093a2f4acbf773ce45f9a76f1775dffa94be5e
MD5 50ad540e283ad0bff7bfcddde28d77e2
BLAKE2b-256 3bddfaf22951fd0914c47db56a1a5af625fed22b708e59cc15e62a01771ce77d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: makeitsample-1.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e1cecc957b6273d2082fc2ebbceaa4d04c7995376b665d57bbe55ef370b17fa7
MD5 c9e4130123aa8f1f37652cd2d7adfd1f
BLAKE2b-256 f3a83ca49ef422d8efcda0f471d6ed2102abe23cc7ef8df70d49c7a4ef8796e7

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