phyla-lang 0.1.0

A procedural language generation library that creates consistent, deterministic constructed languages based on cultural personality traits and geographic influences
Documentation

Phyla-Lang: Procedural Language Generation

A Rust library that generates consistent, deterministic constructed languages (conlangs) based on cultural personality traits and geographic influences.

Features

  • Deterministic Generation: Same inputs always produce the same outputs
  • Cultural Personality Mapping: HEXACO traits influence phonology, morphology, and syntax
  • Geographic Influences: Mountains, coasts, deserts, etc. shape sound systems
  • Infinite Scalability: Generate unlimited unique languages without storing dictionaries
  • Memory Efficient: Store only generation parameters (~3KB per language), not full lexicons
  • Thread-Safe: Language objects are Send + Sync for multi-threaded use

Quick Start

Add to your Cargo.toml:

[dependencies]
phyla-lang = "0.1.0"

Basic Usage

use phyla_lang::{Language, CulturalProfile, Geography};

// Define a cultural profile (HEXACO personality traits, 1-5 scale)
let coastal_culture = CulturalProfile::new(
    4.0, // Agreeableness - cooperative, empathetic
    3.0, // Openness - creative, curious
    2.0, // Conscientiousness - organized, disciplined
    3.0, // Extraversion - social, assertive
    3.0, // Honesty-Humility - sincere, modest
    4.0, // Emotionality - sensitive, expressive
);

// Create a language
let language = Language::from_culture(
    coastal_culture,
    Geography::Coastal,
    12345, // seed for deterministic generation
);

// Translate words
let word = language.translate_word("house");
println!("'house' in this language: {}", word);

// Translate phrases (applies word order rules)
let phrase = language.translate_phrase("I bring the beer quickly");
println!("Translated phrase: {}", phrase);

// Determinism: same input always produces same output
assert_eq!(word, language.translate_word("house"));

How It Works

1. Cultural Parameters → Linguistic Features

The library maps personality traits and geography to linguistic properties:

Personality Traits:

  • High Agreeableness → More nasals (m, n), liquids (l, r), softer sounds
  • Low Agreeableness → More stops (p, t, k), harsh fricatives, consonant clusters
  • High Openness → Larger phoneme inventory, complex syllable structures
  • High Conscientiousness → Regular patterns, SOV word order
  • High Emotionality → More vowels, flowing sounds

Geography:

  • Mountains → Glottal stops, ejectives (k', t'), harsh sounds
  • Coastal → Liquids, flowing sounds, vowel-heavy syllables
  • Desert → Guttural consonants (ħ, ʕ, x), emphatic sounds
  • Forest → Softer sounds, breathy voice, nasals
  • Plains/River Valleys → Balanced phoneme distribution

2. Deterministic Word Generation

  1. Hash concept string + language seed → deterministic seed
  2. Use seeded RNG to determine syllable count
  3. For each syllable:
    • Choose syllable pattern (CV, CVC, CCVC, etc.)
    • Fill with phonemes weighted by category probabilities
  4. Return generated word (always the same for same inputs)

3. Grammar Application

  • Supports 6 word orders: SVO, SOV, VSO, VOS, OVS, OSV
  • Word order is determined by cultural conscientiousness
  • Phrase translation automatically applies word order rules

Examples

Different Cultures, Different Languages

use phyla_lang::{Language, CulturalProfile, Geography};

// Agreeable, emotional coastal folk
let coastal = CulturalProfile::new(4.0, 3.0, 2.0, 3.0, 3.0, 4.0);
let lang1 = Language::from_culture(coastal, Geography::Coastal, 1001);

// Disagreeable, disciplined mountain warriors
let mountain = CulturalProfile::new(1.0, 2.0, 4.0, 2.0, 3.0, 2.0);
let lang2 = Language::from_culture(mountain, Geography::Mountains, 1002);

println!("Coastal: {}", lang1.translate_word("sun"));  // Flowing, soft
println!("Mountain: {}", lang2.translate_word("sun")); // Harsh, abrupt

Run the example:

cargo run --example basic_usage

Use Cases

  1. Game Worlds: Generate distinct languages for factions/cultures
  2. Worldbuilding: Create realistic language families with evolution
  3. Procedural Content: Generate names, places, dialogue
  4. Translation Systems: Convert between constructed languages

Architecture

Core Components

  • LinguisticGenome: Complete specification of a language (phonology, syntax, morphology)
  • PhonemeInventory: Available sounds (consonants and vowels)
  • SyllableStructure: Patterns like CV, CVC, CCVC
  • WordOrder: SVO, SOV, VSO, etc.
  • Language: Public API for word/phrase translation

Performance

  • Word generation: < 100 microseconds
  • Memory per language: < 5KB (genome only)
  • Optional caching for frequently-used words
  • Thread-safe for concurrent use

Testing

Run unit tests:

cargo test

Run integration tests:

cargo test --test integration_test

Run all tests with output:

cargo test -- --nocapture

Design Philosophy

Languages emerge from parameterized cultural profiles rather than being manually designed. This enables:

  1. Infinite scalability: Generate unlimited languages without storing dictionaries
  2. Narrative consistency: Same concept always translates to same word
  3. Memory efficiency: Store only parameters, not full lexicons
  4. Emergent authenticity: Languages feel real because they follow consistent rules

Future Enhancements

  • Writing system generation (orthography)
  • Historical sound changes and language evolution
  • Language family relationships (proto-languages, daughter languages)
  • Dialectal variation
  • Full morphological analysis (affixes, inflections)
  • Phonotactic constraints (rules about sound combinations)

License

Licensed under either of:

at your option.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.