-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
324 lines (274 loc) · 12.9 KB
/
app.py
File metadata and controls
324 lines (274 loc) · 12.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
#!/usr/bin/env python3
"""
Bashkir Language and Culture Promotion App
Main application that integrates all modules from the existing codebase
"""
import os
import sys
from pathlib import Path
import logging
from datetime import datetime
# Import from existing modules
from modules_memory_palace import MemoryPalace, MemoryLocation, MemoryItem
from modules_audio_processor import BashkirAudioProcessor
from modules_major_system import MajorSystemEncoder
from modules_spaced_repetition import SpacedRepetitionSystem
from modules_mnemonic_generator import MnemonicGenerator
from modules_gamification import GamificationSystem, Achievement, Challenge
from modules_visual_renderer import VisualPalaceRenderer
from modules_database import DatabaseManager
from config import *
# Set up logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
class BashkirCultureApp:
"""
Main application class that brings together all functionality to promote Bashkir language and culture
"""
def __init__(self, user_id="default_user"):
self.user_id = user_id
self.database = DatabaseManager()
# Initialize core systems
self.palace = MemoryPalace("Bashkir Cultural Journey", "Traditional Bashkir Village")
self.audio_processor = BashkirAudioProcessor()
self.spaced_repetition = SpacedRepetitionSystem()
self.mnemonic_generator = MnemonicGenerator()
self.gamification = GamificationSystem()
self.visual_renderer = VisualPalaceRenderer()
# Load cultural content
self._load_cultural_content()
logger.info("Bashkir Culture App initialized successfully")
def _load_cultural_content(self):
"""Load initial Bashkir cultural content into the memory palace"""
# Add key Bashkir cultural terms and concepts
cultural_terms = [
{
"bashkir": "Башҡортостан",
"english": "Bashkortostan",
"phonetic": "Bash-kor-tos-tan",
"location_id": 1,
"cultural_context": "The Republic of Bashkortostan is a federal subject of Russia located in the Ural Mountains region."
},
{
"bashkir": "Башҡорт",
"english": "Bashkir",
"phonetic": "Bash-kort",
"location_id": 1,
"cultural_context": "The Bashkir people are a Turkic ethnic group native to the Bashkortostan region."
},
{
"bashkir": "Урал-Батыр",
"english": "Ural-Batyr",
"phonetic": "U-ral Ba-tir",
"location_id": 2,
"cultural_context": "The greatest epic of the Bashkir people, telling the story of the hero Ural-Batyr."
},
{
"bashkir": "Куралай",
"english": "Kuralay",
"phonetic": "Ku-ra-lay",
"location_id": 2,
"cultural_context": "A traditional Bashkir musical instrument similar to a flute."
},
{
"bashkir": "Тирмә",
"english": "Yurt",
"phonetic": "Tir-ma",
"location_id": 3,
"cultural_context": "Traditional nomadic dwelling of the Bashkir people."
},
{
"bashkir": "Бал",
"english": "Honey",
"phonetic": "Bal",
"location_id": 5,
"cultural_context": "Bashkir honey is world-renowned for its quality, and beekeeping is an important cultural practice."
},
{
"bashkir": "Салауат Юлаев",
"english": "Salawat Yulaev",
"phonetic": "Sa-la-wat Yu-la-ev",
"location_id": 6,
"cultural_context": "National hero of the Bashkir people, poet, and leader of the peasant war."
},
{
"bashkir": "Күрәй",
"english": "Kurey",
"phonetic": "Ku-rey",
"location_id": 7,
"cultural_context": "Traditional Bashkir feather grass, a symbol of the republic."
}
]
# Add terms to the memory palace
for term in cultural_terms:
self.palace.add_word(
bashkir=term["bashkir"],
english=term["english"],
phonetic=term["phonetic"],
location_id=term["location_id"],
cultural_context=term["cultural_context"]
)
logger.info(f"Loaded {len(cultural_terms)} cultural terms into the memory palace")
def display_palace_map(self):
"""Display visual representation of the memory palace"""
print("\n=== BASHKIR MEMORY PALACE MAP ===")
print(f"Theme: {self.palace.theme}")
print(f"Name: {self.palace.name}")
print("\nLocations in the Palace:")
for location_id, location in self.palace.locations.items():
words_here = self.palace.get_words_at_location(location_id)
print(f"\n📍 Location {location_id}: {location.name}")
print(f" Description: {location.description}")
print(f" Cultural Significance: {location.cultural_significance}")
print(f" Connected to: {location.connected_to}")
print(f" Words stored here: {len(words_here)}")
for word in words_here:
print(f" • {word.bashkir_word} ({word.phonetic}) - {word.english_translation}")
print(f" Cultural context: {word.cultural_context[:60]}...")
def start_learning_session(self):
"""Start an interactive learning session"""
print("\n🌟 WELCOME TO THE BASHKIR LANGUAGE AND CULTURE LEARNING APP! 🌟")
print("This app helps you learn Bashkir language and culture through memory techniques.")
while True:
print("\n--- MENU ---")
print("1. Browse the Bashkir Memory Palace")
print("2. Practice vocabulary with spaced repetition")
print("3. Listen to Bashkir pronunciation (if audio available)")
print("4. View cultural stories and mnemonics")
print("5. Check your progress")
print("6. Add new Bashkir word")
print("7. Exit")
choice = input("\nEnter your choice (1-7): ").strip()
if choice == "1":
self.display_palace_map()
elif choice == "2":
self.practice_vocabulary()
elif choice == "3":
self.listen_pronunciation()
elif choice == "4":
self.view_cultural_stories()
elif choice == "5":
self.check_progress()
elif choice == "6":
self.add_new_word()
elif choice == "7":
print("\nThank you for learning about Bashkir language and culture!")
print("Until next time! Берәү генә урында! (See you again!)")
break
else:
print("Invalid choice. Please try again.")
def practice_vocabulary(self):
"""Practice vocabulary using spaced repetition"""
print("\n📖 VOCABULARY PRACTICE SESSION")
# Get items for review
items_for_review = []
for item in self.palace.items.values():
# In a real app, we would filter based on next_review date
items_for_review.append(item)
if not items_for_review:
print("No items scheduled for review right now.")
return
# Simple review of all items
for i, item in enumerate(items_for_review[:5]): # Limit to 5 items per session
print(f"\nQuestion {i+1}/{min(len(items_for_review), 5)}:")
print(f"What does '{item.bashkir_word}' mean in English?")
input("Press Enter to see the answer...")
print(f"Answer: {item.english_translation}")
print(f"Pronunciation: {item.phonetic}")
print(f"Cultural context: {item.cultural_context}")
# Update review stats
item.review_count += 1
item.last_reviewed = datetime.now().isoformat()
# Ask user how well they knew it for spaced repetition
rating = input("How well did you know this? (1=hard, 2=good, 3=perfect): ")
try:
rating = int(rating)
if rating in [1, 2, 3]:
# Update spaced repetition schedule
pass # Would implement in full version
except ValueError:
pass
def listen_pronunciation(self):
"""Listen to Bashkir pronunciation if audio is available"""
print("\n🎵 PRONUNCIATION PRACTICE")
available_items = [item for item in self.palace.items.values() if item.audio_path]
if not available_items:
print("No audio pronunciations available yet.")
print("This feature would connect to a Bashkir speech synthesis service.")
return
print("Available pronunciations:")
for i, item in enumerate(available_items):
print(f"{i+1}. {item.bashkir_word} - {item.english_translation}")
try:
selection = int(input("Select an item to hear (or press Enter to skip): ")) - 1
if 0 <= selection < len(available_items):
item = available_items[selection]
print(f"Playing pronunciation for: {item.bashkir_word}")
# In a real app, this would play the audio file
print("(Audio playback would happen here)")
except (ValueError, IndexError):
print("Invalid selection.")
def view_cultural_stories(self):
"""View cultural stories and mnemonics"""
print("\n📚 BASHKIR CULTURAL STORIES")
for location_id, location in self.palace.locations.items():
words_here = self.palace.get_words_at_location(location_id)
if words_here:
print(f"\n🏛️ Location: {location.name}")
print(f" Cultural Significance: {location.cultural_significance}")
for item in words_here:
print(f" Word: {item.bashkir_word}")
print(f" Meaning: {item.english_translation}")
print(f" Mnemonic: {item.image_mnemonic[:100]}...")
print(f" Context: {item.cultural_context}")
print()
def check_progress(self):
"""Check learning progress"""
print("\n📊 YOUR LEARNING PROGRESS")
stats = self.palace.get_statistics()
print(f"Total words in palace: {stats['total_words']}")
print(f"Words reviewed: {stats['reviewed_words']}")
print(f"Total reviews completed: {stats['total_reviews']}")
print(f"Total locations: {stats['total_locations']}")
print(f"Locations with words: {stats['locations_with_words']}")
print("\nWords by location:")
for location, count in stats['words_by_location'].items():
print(f" {location}: {count} words")
def add_new_word(self):
"""Add a new Bashkir word to the memory palace"""
print("\n➕ ADD NEW BASHKIR WORD")
bashkir_word = input("Enter Bashkir word: ").strip()
if not bashkir_word:
print("Word cannot be empty.")
return
english_translation = input("Enter English translation: ").strip()
phonetic = input("Enter phonetic transcription: ").strip()
print("\nAvailable locations:")
for lid, loc in self.palace.locations.items():
print(f" {lid}. {loc.name}")
try:
location_id = int(input("Select location ID (1-8): "))
if location_id not in self.palace.locations:
print("Invalid location ID.")
return
except ValueError:
print("Invalid location ID.")
return
cultural_context = input("Enter cultural context (optional): ").strip()
self.palace.add_word(
bashkir=bashkir_word,
english=english_translation,
phonetic=phonetic,
location_id=location_id,
cultural_context=cultural_context
)
print(f"Successfully added '{bashkir_word}' to the memory palace!")
def main():
"""Main entry point"""
print("🚀 Initializing Bashkir Language and Culture Promotion App...")
# Create the app
app = BashkirCultureApp()
# Start the learning session
app.start_learning_session()
if __name__ == "__main__":
main()