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("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-0.0.1.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

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

makeitsample-0.0.1-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: makeitsample-0.0.1.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

Hashes for makeitsample-0.0.1.tar.gz
Algorithm Hash digest
SHA256 305bc59bf4e1818a5f8e18d3bc4c3f3200f1aa536a8fd49c7abd08dba4ff9b83
MD5 cc86629d152ece22ccf6ed9d0734612e
BLAKE2b-256 472e53e9a98482bdeeba1b090feb06bddc7986c45b76aed9b5fd8943a93088a2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: makeitsample-0.0.1-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

Hashes for makeitsample-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8d93aaf0f31fd6fc1676824a6912e79298f2bbd3de76a373c2905242bdf002a0
MD5 bdedc324022c6cde015913fd89c0591d
BLAKE2b-256 b5a37448c56457d6c2e73657f2d900603f7cf0df18b4e98fb952bed7effbbe10

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