diff --git a/src/Application/MiniApp/Commands/AddAlphabetLessonWords.cs b/src/Application/MiniApp/Commands/AddAlphabetLessonWords.cs index a478e7c1..296f63cc 100644 --- a/src/Application/MiniApp/Commands/AddAlphabetLessonWords.cs +++ b/src/Application/MiniApp/Commands/AddAlphabetLessonWords.cs @@ -42,7 +42,7 @@ public async Task Handle(AddAlphabetLessonWords re } /// -/// After a counted «Знакомство» lesson its phrases and scene words go into the learner's dictionary — the same way +/// After a counted «Знакомство» lesson the words of its phrases and scene (single words, not whole phrases) go into the learner's dictionary — the same way /// as the alphabet words (): from the server's own list, no translator, no /// limits; words already there are left as is, earlier counted lessons' words are added too. /// diff --git a/src/Trale/Lessons/GeorgianVocabIntro/words.json b/src/Trale/Lessons/GeorgianVocabIntro/words.json index a8bc7792..3c0feec0 100644 --- a/src/Trale/Lessons/GeorgianVocabIntro/words.json +++ b/src/Trale/Lessons/GeorgianVocabIntro/words.json @@ -1,5 +1,5 @@ { - "about": "Слова уроков «Знакомства» (intro): фразы урока и слова сцены. Собирается из story.json скриптом tools/intro_story.py. После засчитанного урока сервер кладёт их в словарь ученика (POST /api/miniapp/vocabulary/intro-words).", + "about": "Слова уроков «Знакомства» (intro) для словаря: отдельные слова из фраз урока и слов сцены, без целых фраз. Собирается из story.json скриптом tools/intro_story.py (DICT). После засчитанного урока сервер кладёт их в словарь ученика (POST /api/miniapp/vocabulary/intro-words).", "wordLessons": [ { "id": 1, @@ -20,12 +20,12 @@ "after": 0, "words": [ { - "word": "დილა მშვიდობისა", - "translation": "доброе утро" + "word": "დილა", + "translation": "утро" }, { - "word": "საღამო მშვიდობისა", - "translation": "добрый вечер" + "word": "საღამო", + "translation": "вечер" } ] }, @@ -34,12 +34,16 @@ "after": 0, "words": [ { - "word": "როგორ ხარ?", - "translation": "как дела?" + "word": "როგორ", + "translation": "как" }, { - "word": "კარგად, მადლობა", - "translation": "хорошо, спасибо" + "word": "კარგად", + "translation": "хорошо" + }, + { + "word": "მადლობა", + "translation": "спасибо" }, { "word": "პური", @@ -60,20 +64,24 @@ "after": 0, "words": [ { - "word": "კარგად, შენ?", - "translation": "хорошо, а ты?" + "word": "კარგად", + "translation": "хорошо" + }, + { + "word": "შენ", + "translation": "ты" }, { - "word": "ძალიან კარგად", - "translation": "очень хорошо" + "word": "ძალიან", + "translation": "очень" }, { - "word": "მეც კარგად", - "translation": "я тоже хорошо" + "word": "მეც", + "translation": "я тоже" }, { - "word": "კიდევ?", - "translation": "ещё?" + "word": "კიდევ", + "translation": "ещё" } ] }, @@ -102,8 +110,8 @@ "translation": "остановка" }, { - "word": "გამიჩერეთ!", - "translation": "остановите!" + "word": "გამიჩერეთ", + "translation": "остановите" }, { "word": "აქ", @@ -130,12 +138,12 @@ "after": 0, "words": [ { - "word": "მე მქვია", - "translation": "меня зовут…" + "word": "მე", + "translation": "я" }, { - "word": "მე მქვია კარლოსი", - "translation": "меня зовут Карлос" + "word": "მქვია", + "translation": "меня зовут" }, { "word": "ჩაი", @@ -165,12 +173,20 @@ "after": 0, "words": [ { - "word": "რა გქვია?", - "translation": "как тебя зовут?" + "word": "რა", + "translation": "что" }, { - "word": "გამარჯობა! მე მქვია ნინო. შენ?", - "translation": "Привет! Меня зовут Нино. А тебя?" + "word": "გქვია", + "translation": "тебя зовут" + }, + { + "word": "მქვია", + "translation": "меня зовут" + }, + { + "word": "შენ", + "translation": "ты" }, { "word": "პასპორტი", @@ -199,8 +215,8 @@ "translation": "вино" }, { - "word": "გემრიელია!", - "translation": "вкусно!" + "word": "გემრიელია", + "translation": "вкусно" } ] }, @@ -209,12 +225,20 @@ "after": 0, "words": [ { - "word": "ვინ არის ეს?", - "translation": "кто это?" + "word": "ვინ", + "translation": "кто" + }, + { + "word": "ეს", + "translation": "это" }, { - "word": "ეს ჩემი მეგობარია", - "translation": "это мой друг" + "word": "ჩემი", + "translation": "мой" + }, + { + "word": "მეგობარი", + "translation": "друг" } ] }, @@ -228,16 +252,16 @@ "after": 0, "words": [ { - "word": "საიდან ხარ?", - "translation": "откуда ты?" + "word": "საიდან", + "translation": "откуда" }, { - "word": "მე ვარ საქართველოდან", - "translation": "я из Грузии" + "word": "საქართველო", + "translation": "Грузия" }, { - "word": "მე ვარ ესპანეთიდან", - "translation": "я из Испании" + "word": "ესპანეთი", + "translation": "Испания" } ] }, @@ -246,8 +270,8 @@ "after": 0, "words": [ { - "word": "საფრანგეთიდან", - "translation": "из Франции" + "word": "საფრანგეთი", + "translation": "Франция" } ] }, @@ -265,8 +289,12 @@ "translation": "посылка" }, { - "word": "ეს შენია?", - "translation": "это твоё?" + "word": "ეს", + "translation": "это" + }, + { + "word": "შენი", + "translation": "твой" } ] }, @@ -275,8 +303,12 @@ "after": 0, "words": [ { - "word": "სასიამოვნოა! საქართველო მოგწონს?", - "translation": "Приятно! Тебе нравится Грузия?" + "word": "სასიამოვნოა", + "translation": "приятно познакомиться" + }, + { + "word": "მოგწონს", + "translation": "тебе нравится" } ] }, @@ -285,12 +317,8 @@ "after": 0, "words": [ { - "word": "მე ვცხოვრობ თბილისში", - "translation": "я живу в Тбилиси" - }, - { - "word": "ვცხოვრობ ბათუმში", - "translation": "живу в Батуми" + "word": "ვცხოვრობ", + "translation": "я живу" } ] }, @@ -298,10 +326,6 @@ "id": 19, "after": 0, "words": [ - { - "word": "ქუთაისში", - "translation": "в Кутаиси" - }, { "word": "მარჯვნივ", "translation": "направо" @@ -316,7 +340,7 @@ }, { "word": "გააჩერე", - "translation": "останови здесь" + "translation": "останови" } ] }, @@ -325,16 +349,20 @@ "after": 0, "words": [ { - "word": "მე ვარ სტუდენტი", - "translation": "я студент" + "word": "სტუდენტი", + "translation": "студент" }, { "word": "ექიმი", "translation": "врач" }, { - "word": "ის არის მასწავლებელი", - "translation": "он/она учитель" + "word": "ის", + "translation": "он/она" + }, + { + "word": "მასწავლებელი", + "translation": "учитель" } ] }, @@ -343,8 +371,12 @@ "after": 0, "words": [ { - "word": "შენ რა პროფესია გაქვს?", - "translation": "какая у тебя профессия?" + "word": "პროფესია", + "translation": "профессия" + }, + { + "word": "გაქვს", + "translation": "у тебя есть" } ] }, @@ -357,8 +389,12 @@ "translation": "я работаю" }, { - "word": "რამდენი ღირს?", - "translation": "сколько стоит?" + "word": "რამდენი", + "translation": "сколько" + }, + { + "word": "ღირს", + "translation": "стоит" }, { "word": "ლარი", @@ -371,8 +407,16 @@ "after": 0, "words": [ { - "word": "საქართველო ძალიან ლამაზია", - "translation": "Грузия очень красивая" + "word": "საქართველო", + "translation": "Грузия" + }, + { + "word": "ძალიან", + "translation": "очень" + }, + { + "word": "ლამაზი", + "translation": "красивый" } ] }, @@ -430,16 +474,24 @@ "after": 0, "words": [ { - "word": "მე მყავს ერთი ძმა და ერთი და", - "translation": "у меня есть один брат и одна сестра" + "word": "მყავს", + "translation": "у меня есть (о людях)" + }, + { + "word": "ერთი", + "translation": "один" }, { - "word": "მე მყავს და", - "translation": "у меня есть сестра" + "word": "ძმა", + "translation": "брат" + }, + { + "word": "და", + "translation": "сестра" }, { - "word": "მე მყავს ძაღლი", - "translation": "у меня есть собака" + "word": "ძაღლი", + "translation": "собака" }, { "word": "კატა", @@ -452,8 +504,12 @@ "after": 0, "words": [ { - "word": "მე მაქვს მანქანა", - "translation": "у меня есть машина" + "word": "მაქვს", + "translation": "у меня есть (о вещах)" + }, + { + "word": "მანქანა", + "translation": "машина" }, { "word": "ჩემოდანი", @@ -497,12 +553,20 @@ "after": 0, "words": [ { - "word": "მიყვარს საქართველო", - "translation": "я люблю Грузию" + "word": "მიყვარს", + "translation": "я люблю" + }, + { + "word": "საქართველო", + "translation": "Грузия" + }, + { + "word": "არ", + "translation": "не" }, { - "word": "არ ვიცი", - "translation": "не знаю" + "word": "ვიცი", + "translation": "я знаю" } ] }, @@ -516,12 +580,12 @@ "after": 0, "words": [ { - "word": "გაუმარჯოს!", + "word": "გაუმარჯოს", "translation": "за здоровье! (тост)" }, { - "word": "გაუმარჯოს საქართველოს!", - "translation": "да здравствует Грузия!" + "word": "საქართველო", + "translation": "Грузия" }, { "word": "ხინკალი", diff --git a/src/Trale/miniapp-src/src/api.ts b/src/Trale/miniapp-src/src/api.ts index bdd19dc6..9745115f 100644 --- a/src/Trale/miniapp-src/src/api.ts +++ b/src/Trale/miniapp-src/src/api.ts @@ -168,7 +168,7 @@ export const api = { body: JSON.stringify({ lessonId }) }), - /** Слова засчитанного урока «Знакомства» (фразы и слова сцены) — в «Словарь». Как у алфавита: список — серверный. */ + /** Слова засчитанного урока «Знакомства» (отдельные слова из его фраз и сцены, не фразы) — в «Словарь». Как у алфавита: список — серверный. */ addIntroWords: (lessonId: number) => request<{ words: { word: string; translation: string; added: boolean }[]; added: number }>('/api/miniapp/vocabulary/intro-words', { method: 'POST', diff --git a/src/Trale/miniapp-src/src/intro/scenes/StoryFinale.test.tsx b/src/Trale/miniapp-src/src/intro/scenes/StoryFinale.test.tsx index afd17335..20b0413e 100644 --- a/src/Trale/miniapp-src/src/intro/scenes/StoryFinale.test.tsx +++ b/src/Trale/miniapp-src/src/intro/scenes/StoryFinale.test.tsx @@ -2,7 +2,7 @@ import React from 'react' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { act, fireEvent, render, screen } from '@testing-library/react' import { setMuted } from '../../alphabet/games/fx' -import { introLesson, newPhrases, sceneWords } from '../story' +import { introLesson } from '../story' import StoryFinale from './StoryFinale' vi.mock('../../api', () => ({ api: { addIntroWords: vi.fn() } })) @@ -16,15 +16,16 @@ describe('StoryFinale', () => { it('слова урока уходят в словарь: счётчик растёт, в первых уроках — как его найти, кнопка открывает словарь', async () => { vi.useFakeTimers() const lesson = introLesson(3) - const all = [...newPhrases(lesson), ...sceneWords(lesson)] - addIntroWords.mockResolvedValue({ words: all.map(p => ({ word: p.geo, translation: p.ru, added: true })), added: all.length }) + // В словарь идут отдельные слова из фраз урока, не сами фразы. + const words = [['როგორ', 'как'], ['კარგად', 'хорошо'], ['მადლობა', 'спасибо'], ['პური', 'хлеб']] + addIntroWords.mockResolvedValue({ words: words.map(([word, translation]) => ({ word, translation, added: true })), added: words.length }) const onVocabulary = vi.fn() render( {}} onVocabulary={onVocabulary} />) await act(async () => { await vi.advanceTimersByTimeAsync(100) }) await act(async () => { await vi.advanceTimersByTimeAsync(5000) }) expect(addIntroWords).toHaveBeenCalledWith(3) expect(screen.getByTestId('finale-dict').textContent).toContain('в твоём словаре') - expect(screen.getByTestId('dict-count').textContent).toBe(String(all.length)) + expect(screen.getByTestId('dict-count').textContent).toBe(String(words.length)) expect(screen.getByTestId('finale-dict-tip')).toBeTruthy() fireEvent.click(screen.getByTestId('finale-open-dict')) expect(onVocabulary).toHaveBeenCalled() diff --git a/src/Trale/miniapp-src/src/intro/scenes/StoryFinale.tsx b/src/Trale/miniapp-src/src/intro/scenes/StoryFinale.tsx index 2b50f278..3b393b46 100644 --- a/src/Trale/miniapp-src/src/intro/scenes/StoryFinale.tsx +++ b/src/Trale/miniapp-src/src/intro/scenes/StoryFinale.tsx @@ -15,8 +15,8 @@ const EXPLAIN_DICT_UNTIL = 3 /** * Праздник после урока без ошибок: что теперь умеешь (новые фразы урока), где ты в истории - * (акт и сколько уроков акта позади) и что дальше. Урок засчитан — его фразы и слова сцены сервер - * кладёт в личный словарь: они влетают в значок «Словарь», рядом — «открыть словарь». + * (акт и сколько уроков акта позади) и что дальше. Урок засчитан — слова из его фраз и сцены сервер + * кладёт в личный словарь (отдельными словами, не фразами): они влетают в значок «Словарь», рядом — «открыть словарь». */ export default function StoryFinale({ lesson, onNext, onVocabulary }: { lesson: IntroLesson; onNext: () => void; onVocabulary?: () => void }) { const act = actOf(lesson) @@ -46,8 +46,10 @@ export default function StoryFinale({ lesson, onNext, onVocabulary }: { lesson: const quick = reducedMotion() void (async () => { await new Promise(r => setTimeout(r, quick ? 0 : 900)) - for (let i = 0; i < all.length && alive; i++) { - void flyGhost(cards.current[all[i].id] ?? null, chip.current, all[i].geo, 420, 'font-geo text-[15px]') + // В словарь идут отдельные слова, не фразы: каждое вылетает из карточки фразы, где оно встретилось. + for (let i = 0; i < saved.length && alive; i++) { + const from = all.find(p => p.geo.includes(saved[i].slice(0, -1))) ?? all[0] + void flyGhost(from ? cards.current[from.id] ?? null : null, chip.current, saved[i], 420, 'font-geo text-[15px]') await new Promise(r => setTimeout(r, quick ? 0 : 260)) if (!alive) return haptic('tap'); sound.snap(i) diff --git a/src/Trale/miniapp-src/src/intro/words.test.ts b/src/Trale/miniapp-src/src/intro/words.test.ts index b654125b..966d8d88 100644 --- a/src/Trale/miniapp-src/src/intro/words.test.ts +++ b/src/Trale/miniapp-src/src/intro/words.test.ts @@ -2,15 +2,28 @@ import { describe, expect, it } from 'vitest' import story from './story.json' import words from '../../../Lessons/GeorgianVocabIntro/words.json' -// Слова «Знакомства», которые сервер кладёт в словарь, — это фразы урока и слова сцены из story.json -// (файл собирает tools/intro_story.py; если тест упал — перезапусти скрипт). +// Слова «Знакомства», которые сервер кладёт в словарь, — отдельные слова из фраз урока и слов сцены story.json, +// не сами фразы (файл собирает tools/intro_story.py; если тест упал — перезапусти скрипт). describe('intro words.json', () => { - it('у каждого урока — его фразы и слова сцены, с переводом из истории', () => { - const P = story.phrases as Record - const want = story.lessons.map(l => ({ - id: l.id, - words: [...new Set([...l.new, ...((l as { scene?: string[] }).scene ?? [])])].map(id => ({ word: P[id].geo.replace('…', '').trim(), translation: P[id].ru })) - })) - expect(words.wordLessons.map(l => ({ id: l.id, words: l.words }))).toEqual(want) + const P = story.phrases as Record + const phrasesOf = (id: number) => { + const l = story.lessons.find(x => x.id === id)! + return [...l.new, ...((l as { scene?: string[] }).scene ?? [])].map(p => P[p].geo) + } + + it('у каждого урока истории — свой список', () => { + expect(words.wordLessons.map(l => l.id)).toEqual(story.lessons.map(l => l.id)) + }) + + it('в словаре только отдельные слова, без фраз и знаков', () => { + const all = words.wordLessons.flatMap(l => l.words) + expect(all.length).toBeGreaterThan(0) + expect(all.filter(w => /[\s?!,.…]/.test(w.word) || !w.translation)).toEqual([]) + }) + + it('каждое слово встречается во фразах своего урока (словарная форма — с тем же началом)', () => { + const stray = words.wordLessons.flatMap(l => + l.words.filter(w => !phrasesOf(l.id).some(g => g.includes(w.word.length > 3 ? w.word.slice(0, -1) : w.word))).map(w => `${l.id}: ${w.word}`)) + expect(stray).toEqual([]) }) }) diff --git a/tests/Application.UnitTests/Tests/AddIntroLessonWordsCommandTests.cs b/tests/Application.UnitTests/Tests/AddIntroLessonWordsCommandTests.cs index 2626f18d..0f0d8230 100644 --- a/tests/Application.UnitTests/Tests/AddIntroLessonWordsCommandTests.cs +++ b/tests/Application.UnitTests/Tests/AddIntroLessonWordsCommandTests.cs @@ -12,7 +12,7 @@ namespace Application.UnitTests.Tests; /// -/// After a counted «Знакомство» lesson its phrases and scene words go into the dictionary from the server's own +/// After a counted «Знакомство» lesson the words of its phrases and scene go into the dictionary from the server's own /// list: only for a counted intro lesson, without duplicates, earlier counted lessons included. /// public class AddIntroLessonWordsCommandTests : CommandTestsBase @@ -22,7 +22,7 @@ private sealed class Words : IIntroLessonWords public IReadOnlyList WordLessons { get; } = [ new(1, 0, [new("გამარჯობა", "здравствуй"), new("ნახვამდის", "до свидания")]), - new(3, 0, [new("როგორ ხარ?", "как дела?"), new("პური", "хлеб")]) + new(3, 0, [new("როგორ", "как"), new("პური", "хлеб")]) ]; public IReadOnlyList WordsOf(int lessonId) => WordLessons.FirstOrDefault(l => l.Id == lessonId)?.Words ?? []; @@ -67,7 +67,7 @@ public async Task Adds_the_words_of_this_and_earlier_counted_intro_lessons_once( var result = (await Add(3)).ShouldBeOfType(); result.AddedCount.ShouldBe(4); - result.Words.Select(w => w.Word).ShouldBe(["როგორ ხარ?", "პური"]); + result.Words.Select(w => w.Word).ShouldBe(["როგორ", "პური"]); (await Dictionary()).Single(e => e.Word == "პური").Definition.ShouldBe("хлеб"); var again = (await Add(3)).ShouldBeOfType(); diff --git a/tests/IntegrationTests/MiniApp/AlphabetLessonWordsTests.cs b/tests/IntegrationTests/MiniApp/AlphabetLessonWordsTests.cs index 0532e813..e81942fc 100644 --- a/tests/IntegrationTests/MiniApp/AlphabetLessonWordsTests.cs +++ b/tests/IntegrationTests/MiniApp/AlphabetLessonWordsTests.cs @@ -103,22 +103,31 @@ public async Task A_lesson_passed_with_one_slip_still_puts_its_words_into_the_di } [Test] - public async Task A_counted_intro_lesson_puts_its_phrases_and_scene_words_into_the_dictionary() + public async Task A_counted_intro_lesson_puts_the_words_of_its_phrases_and_scene_into_the_dictionary() { - // Урок 3 «Знакомства»: როგორ ხარ?, კარგად, მადლობა и слова сцены пекарни. + // Урок 3 «Знакомства»: из როგორ ხარ? и კარგად, მადლობა — их слова, плюс слова сцены пекарни. var words = new IntroLessonWords().WordsOf(3); (await Post("progress/lesson-complete", new { moduleId = "intro", lessonId = 3, correct = 5, total = 5 })) .StatusCode.Should().Be(HttpStatusCode.OK); var body = JsonNode.Parse(await (await Post("vocabulary/intro-words", new { lessonId = 3 })).Content.ReadAsStringAsync())!; body["words"]!.AsArray().Select(w => w!["word"]!.GetValue()).Should().Equal(words.Select(w => w.Word)); - words.Select(w => w.Word).Should().Contain(["როგორ ხარ?", "პური"]); + words.Select(w => w.Word).Should().Contain(["როგორ", "კარგად", "მადლობა", "პური"]); (await Dictionary()).Select(e => e.Word).Should().BeEquivalentTo(words.Select(w => w.Word)); (await Post("vocabulary/intro-words", new { lessonId = 4 })).StatusCode.Should().Be(HttpStatusCode.Conflict); (await Post("vocabulary/intro-words", new { lessonId = 99 })).StatusCode.Should().Be(HttpStatusCode.NotFound); } + [Test] + public void The_intro_dictionary_gets_single_words_not_phrases() + { + // Словарь — про слова: целую фразу неудобно учить карточкой и проходить в квизе. + var words = new IntroLessonWords().WordLessons.SelectMany(l => l.Words).ToList(); + words.Should().NotBeEmpty(); + words.Where(w => w.Word.Contains(' ') || w.Word.IndexOfAny(['?', '!', ',', '.', '…']) >= 0).Should().BeEmpty(); + } + [Test] public async Task The_server_word_list_is_the_lesson_theory() { diff --git a/tools/intro_story.py b/tools/intro_story.py index da8e0f0f..c1128c66 100644 --- a/tools/intro_story.py +++ b/tools/intro_story.py @@ -292,14 +292,72 @@ def write_questions(): (LESSONS_DIR / ("questions.json" if lesson["id"] == 1 else f'questions{lesson["id"]}.json')).write_text(json.dumps(out, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") +# ── Словарь: только отдельные слова ────────────────────────────────────────────────────────────────── +# Фраза из одного слова идёт в словарь как есть (без «?» и «!»). Фразу из нескольких слов в словарь не кладём — +# кладём её слова отсюда: в словарной форме, из разбора фразы в story.json (поле words) или из vocab. +# Пустой список — всё уже есть в других уроках или это имя/город. Новая фраза из нескольких слов без строки +# здесь — ошибка сборки. +DICT = { + "dila": [("დილა", "утро")], + "saghamo": [("საღამო", "вечер")], + "rogor": [("როგორ", "как")], + "kargad_madloba": [("კარგად", "хорошо"), ("მადლობა", "спасибо")], + "kargad_shen": [("კარგად", "хорошо"), ("შენ", "ты")], + "dzalian_kargad": [("ძალიან", "очень"), ("კარგად", "хорошо")], + "mets_kargad": [("მეც", "я тоже"), ("კარგად", "хорошо")], + "me_mkvia": [("მე", "я"), ("მქვია", "меня зовут")], + "me_mkvia_karlosi": [("მქვია", "меня зовут")], + "ra_gkvia": [("რა", "что"), ("გქვია", "тебя зовут")], + "me_mkvia_nino": [("მქვია", "меня зовут"), ("შენ", "ты")], + "vin_aris": [("ვინ", "кто"), ("ეს", "это")], + "es_chemi_megobaria": [("ეს", "это"), ("ჩემი", "мой"), ("მეგობარი", "друг")], + "saidan": [("საიდან", "откуда")], + "sakartvelodan": [("საქართველო", "Грузия")], + "espanetidan": [("ესპანეთი", "Испания")], + "es_shenia": [("ეს", "это"), ("შენი", "твой")], + "mogcons": [("სასიამოვნოა", "приятно познакомиться"), ("მოგწონს", "тебе нравится")], + "tbilisshi": [("ვცხოვრობ", "я живу")], + "batumshi": [("ვცხოვრობ", "я живу")], + "studenti": [("სტუდენტი", "студент")], + "mascavlebeli": [("ის", "он/она"), ("მასწავლებელი", "учитель")], + "ra_profesia": [("პროფესია", "профессия"), ("გაქვს", "у тебя есть")], + "ramdeni_ghirs": [("რამდენი", "сколько"), ("ღირს", "стоит")], + "lamazia": [("საქართველო", "Грузия"), ("ძალიან", "очень"), ("ლამაზი", "красивый")], + "myavs_dzma_da": [("მყავს", "у меня есть (о людях)"), ("ერთი", "один"), ("ძმა", "брат"), ("და", "сестра")], + "myavs_da": [("მყავს", "у меня есть (о людях)"), ("და", "сестра")], + "myavs_dzaghli": [("მყავს", "у меня есть (о людях)"), ("ძაღლი", "собака")], + "makvs_manqana": [("მაქვს", "у меня есть (о вещах)"), ("მანქანა", "машина")], + "miyvars_sakartvelo": [("მიყვარს", "я люблю"), ("საქართველო", "Грузия")], + "ar_vici": [("არ", "не"), ("ვიცი", "я знаю")], + "gaumarjos_sakartvelos": [("გაუმარჯოს", "за здоровье! (тост)"), ("საქართველო", "Грузия")], +} +# Одно слово, но это форма, а в словаре нужна основа (или имя, которому в словаре не место), или перевод уже. +DICT.update({ + "safrangetidan": [("საფრანგეთი", "Франция")], + "kutaisshi": [], + "gaachere": [("გააჩერე", "останови")], +}) + + +def dict_words(pid): + p = P[pid] + if pid in DICT: + return DICT[pid] + geo = clean(p["geo"]).rstrip("?!") + assert " " not in geo, f"фраза {pid} «{geo}»: допиши её слова в DICT" + return [(geo, p["ru"].rstrip("?!"))] + + def write_words(): - """Слова урока — фразы урока и слова сцены: после засчитанного урока они попадают в словарь ученика.""" + """Слова урока — отдельные слова из фраз урока и слов сцены: после засчитанного урока они попадают в словарь ученика.""" lessons = [] for lesson in L: ids = list(dict.fromkeys(lesson["new"] + lesson.get("scene", []))) - lessons.append({"id": lesson["id"], "after": 0, "words": [{"word": clean(P[i]["geo"]), "translation": P[i]["ru"]} for i in ids]}) + words = list(dict.fromkeys(w for i in ids for w in dict_words(i))) + lessons.append({"id": lesson["id"], "after": 0, "words": [{"word": g, "translation": r} for g, r in words]}) out = { - "about": "Слова уроков «Знакомства» (intro): фразы урока и слова сцены. Собирается из story.json скриптом tools/intro_story.py. " + "about": "Слова уроков «Знакомства» (intro) для словаря: отдельные слова из фраз урока и слов сцены, без целых фраз. " + "Собирается из story.json скриптом tools/intro_story.py (DICT). " "После засчитанного урока сервер кладёт их в словарь ученика (POST /api/miniapp/vocabulary/intro-words).", "wordLessons": lessons, }