compare_with_js/
compare_with_js.rs1use phyla_lang::{CulturalProfile, Geography, Language};
10
11fn main() {
12 println!("=== Comparing Rust Implementation with JavaScript Demo ===\n");
13
14 let melodic = create_melodic_coastal();
16 let martial = create_mountain_warriors();
17 let scholarly = create_river_scholars();
18 let desert = create_desert_nomads();
19
20 let test_phrase = "I bring the beer quickly";
22
23 println!("Translating: \"{}\"\n", test_phrase);
24
25 println!("1. Melodic Coastal Folk (Agreeable, Emotional, Open)");
26 println!(" Geography: Coastal plains");
27 println!(" Word Order: {:?}", melodic.word_order());
28 println!(" Translation: \"{}\"", melodic.translate_phrase(test_phrase));
29 println!();
30
31 println!("2. Mountain Warriors (Disagreeable, Conscientious, Brave)");
32 println!(" Geography: Mountains");
33 println!(" Word Order: {:?}", martial.word_order());
34 println!(" Translation: \"{}\"", martial.translate_phrase(test_phrase));
35 println!();
36
37 println!("3. River Valley Scholars (Open, Conscientious, Intellectual)");
38 println!(" Geography: River valleys");
39 println!(" Word Order: {:?}", scholarly.word_order());
40 println!(" Translation: \"{}\"", scholarly.translate_phrase(test_phrase));
41 println!();
42
43 println!("4. Desert Nomads (Independent, Hardy, Traditional)");
44 println!(" Geography: Arid deserts");
45 println!(" Word Order: {:?}", desert.word_order());
46 println!(" Translation: \"{}\"", desert.translate_phrase(test_phrase));
47 println!();
48
49 println!("=== Individual Word Translations ===\n");
51
52 let words = ["water", "sun", "mountain", "warrior", "peace"];
53
54 for word in &words {
55 println!("{:12} → Coastal: {:12} | Mountain: {:12} | Scholar: {:12} | Desert: {:12}",
56 word,
57 melodic.translate_word(word),
58 martial.translate_word(word),
59 scholarly.translate_word(word),
60 desert.translate_word(word),
61 );
62 }
63
64 println!("\n=== Phonological Characteristics ===\n");
65
66 println!("Melodic Coastal Folk:");
67 print_phonology(&melodic);
68
69 println!("\nMountain Warriors:");
70 print_phonology(&martial);
71
72 println!("\nRiver Valley Scholars:");
73 print_phonology(&scholarly);
74
75 println!("\nDesert Nomads:");
76 print_phonology(&desert);
77}
78
79fn create_melodic_coastal() -> Language {
80 let culture = CulturalProfile::new(
82 4.0, 3.0, 2.0, 3.0, 3.0, 4.0, );
89
90 Language::from_culture(culture, Geography::Coastal, 1001)
91}
92
93fn create_mountain_warriors() -> Language {
94 let culture = CulturalProfile::new(
96 1.0, 2.0, 4.0, 4.0, 3.0, 2.0, );
103
104 Language::from_culture(culture, Geography::Mountains, 1002)
105}
106
107fn create_river_scholars() -> Language {
108 let culture = CulturalProfile::new(
110 3.0, 4.0, 4.0, 3.0, 4.0, 3.0, );
117
118 Language::from_culture(culture, Geography::RiverValley, 1003)
119}
120
121fn create_desert_nomads() -> Language {
122 let culture = CulturalProfile::new(
124 2.0, 2.0, 3.0, 3.0, 3.0, 2.0, );
131
132 Language::from_culture(culture, Geography::Desert, 1004)
133}
134
135fn print_phonology(language: &Language) {
136 let genome = &language.genome;
137 let inventory = &genome.phoneme_inventory;
138
139 println!(" Stops: {:?}", inventory.stops.iter().map(|c| &c.0).collect::<Vec<_>>());
140 println!(" Fricatives: {:?}", inventory.fricatives.iter().map(|c| &c.0).collect::<Vec<_>>());
141 println!(" Nasals: {:?}", inventory.nasals.iter().map(|c| &c.0).collect::<Vec<_>>());
142 println!(" Liquids: {:?}", inventory.liquids.iter().map(|c| &c.0).collect::<Vec<_>>());
143 println!(" Vowels: {:?}", inventory.vowels.iter().map(|v| &v.0).collect::<Vec<_>>());
144 println!(" Morphology: {:?}", genome.morphology_type);
145}
146