after Tag added
This commit is contained in:
parent
96621bcb96
commit
15717ff43a
4 changed files with 6330 additions and 5843 deletions
21
doc/Notes.md
21
doc/Notes.md
|
|
@ -33,6 +33,10 @@
|
||||||
- [Fix up of data](#fix-up-of-data)
|
- [Fix up of data](#fix-up-of-data)
|
||||||
- [Gemini initial response](#gemini-initial-response)
|
- [Gemini initial response](#gemini-initial-response)
|
||||||
- [Gemini Response](#gemini-response)
|
- [Gemini Response](#gemini-response)
|
||||||
|
- [SQLite3](#sqlite3)
|
||||||
|
- [how to backup the sqlite3 database](#how-to-backup-the-sqlite3-database)
|
||||||
|
- [how ro alter a table within the data base](#how-ro-alter-a-table-within-the-data-base)
|
||||||
|
- [to examine the PRAGMA table](#to-examine-the-pragma-table)
|
||||||
|
|
||||||
# 1. spanish-voice-trainer
|
# 1. spanish-voice-trainer
|
||||||
# 2. Project Summary:
|
# 2. Project Summary:
|
||||||
|
|
@ -449,4 +453,21 @@ Let's modify your SQLite phrases schema to add columns for word_type (noun, verb
|
||||||
Here is the plan to gracefully adjust your schema and run an updated, data-preserving migration:
|
Here is the plan to gracefully adjust your schema and run an updated, data-preserving migration:
|
||||||
|
|
||||||
This requires adding another column to our database
|
This requires adding another column to our database
|
||||||
|
|
||||||
|
# SQLite3
|
||||||
|
|
||||||
|
## how to backup the sqlite3 database
|
||||||
|
```zsh
|
||||||
|
sqlite3 database/trainer.db ".backup 'database/trainer_backup_$(date +%Y%m%d_%H%M%S).db'"
|
||||||
|
```
|
||||||
|
## how ro alter a table within the data base
|
||||||
|
```zsh
|
||||||
|
sqlite3 spanish_trainer.db "ALTER TABLE translations ADD COLUMN tags TEXT DEFAULT '';"
|
||||||
|
```
|
||||||
|
## to examine the PRAGMA table
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
sqlite3 spanish_trainer.db "PRAGMA table_info(translations);"
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
12133
doc/Notes.pdf
12133
doc/Notes.pdf
File diff suppressed because it is too large
Load diff
19
main.py
19
main.py
|
|
@ -144,6 +144,10 @@ class SpanishTrainerApp(QMainWindow):
|
||||||
self.input_context = QLineEdit()
|
self.input_context = QLineEdit()
|
||||||
self.input_context.setPlaceholderText("e.g., U8_5A")
|
self.input_context.setPlaceholderText("e.g., U8_5A")
|
||||||
|
|
||||||
|
# Explicit Tags field implementation
|
||||||
|
self.input_tags = QLineEdit()
|
||||||
|
self.input_tags.setPlaceholderText("e.g., irregular_er boots_verb (space-separated)")
|
||||||
|
|
||||||
self.input_deck_tag = QLineEdit()
|
self.input_deck_tag = QLineEdit()
|
||||||
self.input_deck_tag.setPlaceholderText("Anki Sub-deck Hierarchy")
|
self.input_deck_tag.setPlaceholderText("Anki Sub-deck Hierarchy")
|
||||||
|
|
||||||
|
|
@ -226,6 +230,7 @@ class SpanishTrainerApp(QMainWindow):
|
||||||
form_layout.addRow(self.input_grammar_note)
|
form_layout.addRow(self.input_grammar_note)
|
||||||
form_layout.addRow("Classification Profile:", self.combo_type)
|
form_layout.addRow("Classification Profile:", self.combo_type)
|
||||||
form_layout.addRow("Source Context ID (Raw):", self.input_context)
|
form_layout.addRow("Source Context ID (Raw):", self.input_context)
|
||||||
|
form_layout.addRow("Anki Note Tags:", self.input_tags)
|
||||||
form_layout.addRow("<b>Target Deck Scope:</b>", self.input_deck_tag)
|
form_layout.addRow("<b>Target Deck Scope:</b>", self.input_deck_tag)
|
||||||
|
|
||||||
crud_buttons = QHBoxLayout()
|
crud_buttons = QHBoxLayout()
|
||||||
|
|
@ -364,7 +369,7 @@ class SpanishTrainerApp(QMainWindow):
|
||||||
conn = get_connection()
|
conn = get_connection()
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
cursor.execute("""
|
cursor.execute("""
|
||||||
SELECT t.translation_id, p1.text, p2.text, p1.word_type, p1.source_context, t.deck_name, t.notes
|
SELECT t.translation_id, p1.text, p2.text, p1.word_type, p1.source_context, t.deck_name, t.notes, t.tags
|
||||||
FROM translations t
|
FROM translations t
|
||||||
JOIN phrases p1 ON t.source_phrase_id = p1.id
|
JOIN phrases p1 ON t.source_phrase_id = p1.id
|
||||||
JOIN phrases p2 ON t.target_phrase_id = p2.id
|
JOIN phrases p2 ON t.target_phrase_id = p2.id
|
||||||
|
|
@ -379,6 +384,7 @@ class SpanishTrainerApp(QMainWindow):
|
||||||
self.input_text_en.setPlainText(str(record[2]))
|
self.input_text_en.setPlainText(str(record[2]))
|
||||||
self.combo_type.setCurrentText(str(record[3]) if record[3] else "phrase")
|
self.combo_type.setCurrentText(str(record[3]) if record[3] else "phrase")
|
||||||
self.input_context.setText(str(record[4]) if record[4] else "")
|
self.input_context.setText(str(record[4]) if record[4] else "")
|
||||||
|
self.input_tags.setText(str(record[7]) if record[7] is not None else "")
|
||||||
self.input_deck_tag.setText(str(record[5]) if record[5] else "General")
|
self.input_deck_tag.setText(str(record[5]) if record[5] else "General")
|
||||||
self.input_grammar_note.setPlainText(str(record[6]) if record[6] is not None else "")
|
self.input_grammar_note.setPlainText(str(record[6]) if record[6] is not None else "")
|
||||||
|
|
||||||
|
|
@ -405,10 +411,10 @@ class SpanishTrainerApp(QMainWindow):
|
||||||
""", (self.input_text_en.toPlainText().strip(), self.combo_type.currentText(), self.input_context.text().strip()))
|
""", (self.input_text_en.toPlainText().strip(), self.combo_type.currentText(), self.input_context.text().strip()))
|
||||||
en_id = cursor.lastrowid
|
en_id = cursor.lastrowid
|
||||||
|
|
||||||
# Build cross-referencing translation relational binding matrix row
|
# Build cross-referencing translation relational binding matrix row complete with tags data
|
||||||
cursor.execute("""
|
cursor.execute("""
|
||||||
INSERT INTO translations (source_phrase_id, target_phrase_id, deck_name, notes) VALUES (?, ?, ?, ?)
|
INSERT INTO translations (source_phrase_id, target_phrase_id, deck_name, notes, tags) VALUES (?, ?, ?, ?, ?)
|
||||||
""", (es_id, en_id, self.input_deck_tag.text().strip() or "General", self.input_grammar_note.toPlainText().strip()))
|
""", (es_id, en_id, self.input_deck_tag.text().strip() or "General", self.input_grammar_note.toPlainText().strip(), self.input_tags.text().strip()))
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
@ -432,8 +438,8 @@ class SpanishTrainerApp(QMainWindow):
|
||||||
(self.input_text_es.toPlainText().strip(), self.combo_type.currentText(), self.input_context.text().strip(), es_id))
|
(self.input_text_es.toPlainText().strip(), self.combo_type.currentText(), self.input_context.text().strip(), es_id))
|
||||||
cursor.execute("UPDATE phrases SET text=?, word_type=?, source_context=? WHERE id=?",
|
cursor.execute("UPDATE phrases SET text=?, word_type=?, source_context=? WHERE id=?",
|
||||||
(self.input_text_en.toPlainText().strip(), self.combo_type.currentText(), self.input_context.text().strip(), en_id))
|
(self.input_text_en.toPlainText().strip(), self.combo_type.currentText(), self.input_context.text().strip(), en_id))
|
||||||
cursor.execute("UPDATE translations SET deck_name=?, notes=? WHERE translation_id=?",
|
cursor.execute("UPDATE translations SET deck_name=?, notes=?, tags=? WHERE translation_id=?",
|
||||||
(self.input_deck_tag.text().strip() or "General", self.input_grammar_note.toPlainText().strip(), tx_id))
|
(self.input_deck_tag.text().strip() or "General", self.input_grammar_note.toPlainText().strip(), self.input_tags.text().strip(), tx_id))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
@ -460,6 +466,7 @@ class SpanishTrainerApp(QMainWindow):
|
||||||
self.input_text_es.clear()
|
self.input_text_es.clear()
|
||||||
self.input_text_en.clear()
|
self.input_text_en.clear()
|
||||||
self.input_grammar_note.clear()
|
self.input_grammar_note.clear()
|
||||||
|
self.input_tags.clear()
|
||||||
|
|
||||||
# =====================================================================
|
# =====================================================================
|
||||||
# 🔊 AUDIO OPERATIONS & FLASHCARD CONTROL
|
# 🔊 AUDIO OPERATIONS & FLASHCARD CONTROL
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in a new issue