ru-flashcards 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +80 -2
- package/bin/ru-flashcards.mjs +5 -0
- package/data/a1.json +102 -0
- package/data/a2.json +102 -0
- package/package.json +46 -4
- package/src/cards.ts +55 -0
- package/src/cli.ts +110 -0
- package/src/leitner.ts +58 -0
- package/src/speak.ts +24 -0
- package/src/stats.ts +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 akinakkus
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,81 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ru-flashcards
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Russian flashcards in the terminal, for Turkish speakers.** Questions alternate between Russian → Turkish and Turkish → Russian, and words you know come back less often.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
6 cards. Type q to stop.
|
|
7
|
+
|
|
8
|
+
[RU → TR] дом > ev
|
|
9
|
+
✓ correct
|
|
10
|
+
[TR → RU] su > вода
|
|
11
|
+
✓ correct
|
|
12
|
+
[RU → TR] кни́га > kitap
|
|
13
|
+
✓ correct
|
|
14
|
+
[TR → RU] masa > стол
|
|
15
|
+
✓ correct
|
|
16
|
+
[RU → TR] окно́ > penceler
|
|
17
|
+
✗ answer: pencere
|
|
18
|
+
[TR → RU] araba > машина
|
|
19
|
+
✓ correct
|
|
20
|
+
|
|
21
|
+
Score: 5/6
|
|
22
|
+
Boxes 1-5: 25 | 5 | 0 | 0 | 0
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
- **Both directions, in turn.** Odd questions show the Russian word, even ones show the Turkish meaning.
|
|
28
|
+
- **Forgiving answers.** Stress marks, ё/е, capital letters (with Turkish İ/ı rules), punctuation and extra spaces do not count as mistakes. `вода` and `вода́` are both right.
|
|
29
|
+
- **Several accepted meanings.** `друг` accepts both *arkadaş* and *dost*.
|
|
30
|
+
- **Leitner boxes.** A right answer moves a card up a box and waits longer before asking again (box 2: 1 day, 3: 3 days, 4: 7 days, 5: 14 days). A wrong answer sends it back to box 1. Progress is saved in `~/.ru-flashcards/progress.json`.
|
|
31
|
+
- **Hints that are never required.** A prompt like *ay (takvim)* tells you which "ay" is meant (month, not moon); answering just *ay* is still right.
|
|
32
|
+
- **Two decks, 100 words each.** A1 (family, food, home, places, time, adjectives, verbs, colours) and A2 (body, clothes, weather, travel, city, study, hobbies, common verbs) with `--level a2`. Every word has its stress mark, and each deck was checked by two independent language reviewers. Bring your own deck with `--deck`.
|
|
33
|
+
- **More than one right Russian answer.** In Turkish → Russian, *doktor* accepts both `врач` and `до́ктор`, and *satın almak* accepts both aspects, `покупа́ть` and `купи́ть`.
|
|
34
|
+
- **Hear the words.** With `--voice` (macOS), each Russian word is said out loud by the built-in Russian voice: before you answer in Russian → Turkish, after you answer in Turkish → Russian.
|
|
35
|
+
- **Your hardest words.** Every answer is counted. After each session, and with `--stats`, you see how many words you have studied, your success rate and the five words you miss most:
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
Studied: 6/100 words, 6 answers, 50% right
|
|
39
|
+
Hardest words:
|
|
40
|
+
1. кни́га = kitap (1 wrong, 0 right)
|
|
41
|
+
2. стол = masa (1 wrong, 0 right)
|
|
42
|
+
3. маши́на = araba (1 wrong, 0 right)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Run
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx github:akinakkusru-max/ru-flashcards
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Options: `--level a2` (A2 deck; default A1), `--size 20` (cards per session), `--voice` (say words out loud, macOS), `--stats` (progress and hardest words), `--deck my.json`, `--reset` (forget progress), `--help`.
|
|
52
|
+
|
|
53
|
+
A deck is a JSON list:
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
[{ "ru": "вода́", "tr": ["su"] }, { "ru": "врач", "tr": ["doktor"], "alt": ["до́ктор"] }]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`alt` is optional: other Russian words that are also right in the Turkish → Russian direction.
|
|
60
|
+
|
|
61
|
+
The first Turkish meaning is the one shown in the Turkish → Russian direction, so it should point to one word only. Add a hint in parentheses when it could fit two words: `"ay (takvim)"`.
|
|
62
|
+
|
|
63
|
+
## Develop
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npm install
|
|
67
|
+
npm test # 36 tests
|
|
68
|
+
npm start
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The tests also check both decks: unique words, a stress mark on every word with more than one vowel (alternatives too), no Turkish prompt that fits two cards, and no word shared between levels. Each check was tested by breaking a deck on purpose and seeing it fail.
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
MIT
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
### Türkçe özet
|
|
80
|
+
|
|
81
|
+
Terminalde çalışan Rusça kelime kartı programı. Sorular sırayla Rusça → Türkçe ve Türkçe → Rusça gelir. Vurgu işareti, ё/е ve büyük-küçük harf farkı hata sayılmaz. Bildiğin kelimeler üst kutulara geçer ve daha seyrek sorulur (Leitner yöntemi); bilemediğin kelime başa döner. `--voice` ile Mac Rusça kelimeleri sesli okur. A1 ve A2 olmak üzere iki deste var; A2 için `--level a2`.
|
package/data/a1.json
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
[
|
|
2
|
+
{"ru": "дом", "tr": ["ev"]},
|
|
3
|
+
{"ru": "вода́", "tr": ["su"]},
|
|
4
|
+
{"ru": "кни́га", "tr": ["kitap"]},
|
|
5
|
+
{"ru": "стол", "tr": ["masa"]},
|
|
6
|
+
{"ru": "окно́", "tr": ["pencere"]},
|
|
7
|
+
{"ru": "маши́на", "tr": ["araba"]},
|
|
8
|
+
{"ru": "хлеб", "tr": ["ekmek"]},
|
|
9
|
+
{"ru": "мать", "tr": ["anne"]},
|
|
10
|
+
{"ru": "оте́ц", "tr": ["baba"]},
|
|
11
|
+
{"ru": "брат", "tr": ["erkek kardeş", "kardeş", "ağabey"]},
|
|
12
|
+
{"ru": "сестра́", "tr": ["kız kardeş", "kardeş", "abla"]},
|
|
13
|
+
{"ru": "друг", "tr": ["arkadaş", "dost"]},
|
|
14
|
+
{"ru": "го́род", "tr": ["şehir", "kent"]},
|
|
15
|
+
{"ru": "у́лица", "tr": ["sokak", "cadde"]},
|
|
16
|
+
{"ru": "рабо́та", "tr": ["iş"]},
|
|
17
|
+
{"ru": "шко́ла", "tr": ["okul"]},
|
|
18
|
+
{"ru": "день", "tr": ["gün"]},
|
|
19
|
+
{"ru": "ночь", "tr": ["gece"]},
|
|
20
|
+
{"ru": "у́тро", "tr": ["sabah"]},
|
|
21
|
+
{"ru": "ве́чер", "tr": ["akşam"]},
|
|
22
|
+
{"ru": "ко́шка", "tr": ["kedi"]},
|
|
23
|
+
{"ru": "соба́ка", "tr": ["köpek"]},
|
|
24
|
+
{"ru": "молоко́", "tr": ["süt"]},
|
|
25
|
+
{"ru": "я́блоко", "tr": ["elma"]},
|
|
26
|
+
{"ru": "чай", "tr": ["çay"]},
|
|
27
|
+
{"ru": "ко́фе", "tr": ["kahve"]},
|
|
28
|
+
{"ru": "да", "tr": ["evet"]},
|
|
29
|
+
{"ru": "нет", "tr": ["hayır", "yok"]},
|
|
30
|
+
{"ru": "спаси́бо", "tr": ["teşekkürler", "teşekkür ederim", "sağ ol"]},
|
|
31
|
+
{"ru": "пожа́луйста", "tr": ["lütfen", "rica ederim", "buyurun"]},
|
|
32
|
+
{"ru": "ба́бушка", "tr": ["büyükanne", "nine", "babaanne", "anneanne"]},
|
|
33
|
+
{"ru": "де́душка", "tr": ["büyükbaba", "dede"]},
|
|
34
|
+
{"ru": "сын", "tr": ["oğul"]},
|
|
35
|
+
{"ru": "дочь", "tr": ["kız evlat", "kız"]},
|
|
36
|
+
{"ru": "муж", "tr": ["koca", "eş (erkek)"]},
|
|
37
|
+
{"ru": "жена́", "tr": ["eş (kadın)", "hanım", "karı"]},
|
|
38
|
+
{"ru": "ребёнок", "tr": ["çocuk"]},
|
|
39
|
+
{"ru": "челове́к", "tr": ["insan", "kişi"]},
|
|
40
|
+
{"ru": "же́нщина", "tr": ["kadın"]},
|
|
41
|
+
{"ru": "мужчи́на", "tr": ["adam", "erkek (yetişkin)"]},
|
|
42
|
+
{"ru": "сыр", "tr": ["peynir"]},
|
|
43
|
+
{"ru": "мя́со", "tr": ["et"]},
|
|
44
|
+
{"ru": "ры́ба", "tr": ["balık"]},
|
|
45
|
+
{"ru": "яйцо́", "tr": ["yumurta"]},
|
|
46
|
+
{"ru": "са́хар", "tr": ["şeker"]},
|
|
47
|
+
{"ru": "соль", "tr": ["tuz"]},
|
|
48
|
+
{"ru": "дверь", "tr": ["kapı"]},
|
|
49
|
+
{"ru": "стул", "tr": ["sandalye"]},
|
|
50
|
+
{"ru": "крова́ть", "tr": ["yatak"]},
|
|
51
|
+
{"ru": "су́мка", "tr": ["çanta"]},
|
|
52
|
+
{"ru": "ру́чка", "tr": ["tükenmez kalem", "kalem"]},
|
|
53
|
+
{"ru": "каранда́ш", "tr": ["kurşun kalem", "kalem"]},
|
|
54
|
+
{"ru": "ко́мната", "tr": ["oda"]},
|
|
55
|
+
{"ru": "ку́хня", "tr": ["mutfak"]},
|
|
56
|
+
{"ru": "магази́н", "tr": ["mağaza", "dükkan", "dükkân"]},
|
|
57
|
+
{"ru": "больни́ца", "tr": ["hastane"]},
|
|
58
|
+
{"ru": "апте́ка", "tr": ["eczane"]},
|
|
59
|
+
{"ru": "мо́ре", "tr": ["deniz"]},
|
|
60
|
+
{"ru": "река́", "tr": ["nehir", "ırmak"]},
|
|
61
|
+
{"ru": "страна́", "tr": ["ülke"]},
|
|
62
|
+
{"ru": "лес", "tr": ["orman"]},
|
|
63
|
+
{"ru": "год", "tr": ["yıl", "sene"]},
|
|
64
|
+
{"ru": "неде́ля", "tr": ["hafta"]},
|
|
65
|
+
{"ru": "ме́сяц", "tr": ["ay (takvim)"]},
|
|
66
|
+
{"ru": "сего́дня", "tr": ["bugün"]},
|
|
67
|
+
{"ru": "за́втра", "tr": ["yarın"]},
|
|
68
|
+
{"ru": "вчера́", "tr": ["dün"]},
|
|
69
|
+
{"ru": "зима́", "tr": ["kış"]},
|
|
70
|
+
{"ru": "ле́то", "tr": ["yaz (mevsim)"]},
|
|
71
|
+
{"ru": "весна́", "tr": ["ilkbahar", "bahar"]},
|
|
72
|
+
{"ru": "о́сень", "tr": ["sonbahar"]},
|
|
73
|
+
{"ru": "большо́й", "tr": ["büyük"]},
|
|
74
|
+
{"ru": "ма́ленький", "tr": ["küçük"]},
|
|
75
|
+
{"ru": "хоро́ший", "tr": ["iyi (sıfat)"]},
|
|
76
|
+
{"ru": "плохо́й", "tr": ["kötü (sıfat)"]},
|
|
77
|
+
{"ru": "но́вый", "tr": ["yeni"]},
|
|
78
|
+
{"ru": "ста́рый", "tr": ["eski", "yaşlı"]},
|
|
79
|
+
{"ru": "краси́вый", "tr": ["güzel"]},
|
|
80
|
+
{"ru": "горя́чий", "tr": ["sıcak (çay, su)", "kaynar"]},
|
|
81
|
+
{"ru": "холо́дный", "tr": ["soğuk"]},
|
|
82
|
+
{"ru": "чита́ть", "tr": ["okumak"]},
|
|
83
|
+
{"ru": "писа́ть", "tr": ["yazmak"]},
|
|
84
|
+
{"ru": "говори́ть", "tr": ["konuşmak", "söylemek"]},
|
|
85
|
+
{"ru": "знать", "tr": ["bilmek"]},
|
|
86
|
+
{"ru": "жить", "tr": ["yaşamak", "oturmak (bir yerde)"]},
|
|
87
|
+
{"ru": "рабо́тать", "tr": ["çalışmak"]},
|
|
88
|
+
{"ru": "люби́ть", "tr": ["sevmek"]},
|
|
89
|
+
{"ru": "есть", "tr": ["yemek yemek", "yemek"]},
|
|
90
|
+
{"ru": "пить", "tr": ["içmek"]},
|
|
91
|
+
{"ru": "спать", "tr": ["uyumak"]},
|
|
92
|
+
{"ru": "идти́", "tr": ["yürüyerek gitmek", "gitmek", "yürümek"]},
|
|
93
|
+
{"ru": "смотре́ть", "tr": ["bakmak", "izlemek", "seyretmek"]},
|
|
94
|
+
{"ru": "слу́шать", "tr": ["dinlemek"]},
|
|
95
|
+
{"ru": "понима́ть", "tr": ["anlamak"]},
|
|
96
|
+
{"ru": "де́лать", "tr": ["yapmak"]},
|
|
97
|
+
{"ru": "кра́сный", "tr": ["kırmızı"]},
|
|
98
|
+
{"ru": "си́ний", "tr": ["koyu mavi", "mavi", "lacivert"]},
|
|
99
|
+
{"ru": "зелёный", "tr": ["yeşil"]},
|
|
100
|
+
{"ru": "бе́лый", "tr": ["beyaz"]},
|
|
101
|
+
{"ru": "чёрный", "tr": ["siyah", "kara"]}
|
|
102
|
+
]
|
package/data/a2.json
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
[
|
|
2
|
+
{"ru": "голова́", "tr": ["baş", "kafa"]},
|
|
3
|
+
{"ru": "рука́", "tr": ["el", "kol"]},
|
|
4
|
+
{"ru": "нога́", "tr": ["ayak", "bacak"]},
|
|
5
|
+
{"ru": "глаз", "tr": ["göz"]},
|
|
6
|
+
{"ru": "рот", "tr": ["ağız"]},
|
|
7
|
+
{"ru": "нос", "tr": ["burun"]},
|
|
8
|
+
{"ru": "у́хо", "tr": ["kulak"]},
|
|
9
|
+
{"ru": "во́лосы", "tr": ["saç", "saçlar"]},
|
|
10
|
+
{"ru": "зуб", "tr": ["diş"]},
|
|
11
|
+
{"ru": "се́рдце", "tr": ["kalp", "yürek"]},
|
|
12
|
+
{"ru": "руба́шка", "tr": ["gömlek"]},
|
|
13
|
+
{"ru": "пла́тье", "tr": ["elbise"]},
|
|
14
|
+
{"ru": "брю́ки", "tr": ["pantolon"]},
|
|
15
|
+
{"ru": "ю́бка", "tr": ["etek"]},
|
|
16
|
+
{"ru": "ку́ртка", "tr": ["mont", "ceket"]},
|
|
17
|
+
{"ru": "пальто́", "tr": ["palto", "kaban"]},
|
|
18
|
+
{"ru": "ша́пка", "tr": ["bere", "şapka"]},
|
|
19
|
+
{"ru": "дождь", "tr": ["yağmur"]},
|
|
20
|
+
{"ru": "снег", "tr": ["kar"]},
|
|
21
|
+
{"ru": "со́лнце", "tr": ["güneş"]},
|
|
22
|
+
{"ru": "ве́тер", "tr": ["rüzgâr", "rüzgar"]},
|
|
23
|
+
{"ru": "не́бо", "tr": ["gökyüzü", "gök"]},
|
|
24
|
+
{"ru": "пого́да", "tr": ["hava durumu", "hava"]},
|
|
25
|
+
{"ru": "гора́", "tr": ["dağ"]},
|
|
26
|
+
{"ru": "о́зеро", "tr": ["göl"]},
|
|
27
|
+
{"ru": "де́рево", "tr": ["ağaç"]},
|
|
28
|
+
{"ru": "по́езд", "tr": ["tren"]},
|
|
29
|
+
{"ru": "самолёт", "tr": ["uçak"]},
|
|
30
|
+
{"ru": "авто́бус", "tr": ["otobüs"]},
|
|
31
|
+
{"ru": "вокза́л", "tr": ["gar", "istasyon"]},
|
|
32
|
+
{"ru": "аэропо́рт", "tr": ["havalimanı", "havaalanı"]},
|
|
33
|
+
{"ru": "биле́т", "tr": ["bilet"]},
|
|
34
|
+
{"ru": "доро́га", "tr": ["yol"]},
|
|
35
|
+
{"ru": "гости́ница", "tr": ["otel"], "alt": ["оте́ль"]},
|
|
36
|
+
{"ru": "па́спорт", "tr": ["pasaport"]},
|
|
37
|
+
{"ru": "чемода́н", "tr": ["bavul", "valiz"]},
|
|
38
|
+
{"ru": "библиоте́ка", "tr": ["kütüphane"]},
|
|
39
|
+
{"ru": "ры́нок", "tr": ["pazar yeri", "pazar", "çarşı"]},
|
|
40
|
+
{"ru": "музе́й", "tr": ["müze"]},
|
|
41
|
+
{"ru": "теа́тр", "tr": ["tiyatro"]},
|
|
42
|
+
{"ru": "парк", "tr": ["park"]},
|
|
43
|
+
{"ru": "по́чта", "tr": ["postane", "posta"]},
|
|
44
|
+
{"ru": "банк", "tr": ["banka"]},
|
|
45
|
+
{"ru": "рестора́н", "tr": ["restoran", "lokanta"]},
|
|
46
|
+
{"ru": "врач", "tr": ["doktor", "hekim"], "alt": ["до́ктор"]},
|
|
47
|
+
{"ru": "боле́знь", "tr": ["hastalık"]},
|
|
48
|
+
{"ru": "лека́рство", "tr": ["ilaç"]},
|
|
49
|
+
{"ru": "университе́т", "tr": ["üniversite"]},
|
|
50
|
+
{"ru": "уро́к", "tr": ["ders"], "alt": ["заня́тие"]},
|
|
51
|
+
{"ru": "экза́мен", "tr": ["sınav"]},
|
|
52
|
+
{"ru": "вопро́с", "tr": ["soru"]},
|
|
53
|
+
{"ru": "отве́т", "tr": ["cevap", "yanıt"]},
|
|
54
|
+
{"ru": "де́ньги", "tr": ["para"]},
|
|
55
|
+
{"ru": "сло́во", "tr": ["kelime", "sözcük", "söz"]},
|
|
56
|
+
{"ru": "язы́к", "tr": ["dil"]},
|
|
57
|
+
{"ru": "о́вощи", "tr": ["sebze", "sebzeler"]},
|
|
58
|
+
{"ru": "фру́кты", "tr": ["meyve", "meyveler"]},
|
|
59
|
+
{"ru": "суп", "tr": ["çorba"]},
|
|
60
|
+
{"ru": "сок", "tr": ["meyve suyu"]},
|
|
61
|
+
{"ru": "карто́фель", "tr": ["patates"], "alt": ["карто́шка"]},
|
|
62
|
+
{"ru": "му́зыка", "tr": ["müzik"]},
|
|
63
|
+
{"ru": "фильм", "tr": ["film"]},
|
|
64
|
+
{"ru": "спорт", "tr": ["spor"]},
|
|
65
|
+
{"ru": "игра́", "tr": ["oyun"]},
|
|
66
|
+
{"ru": "пе́сня", "tr": ["şarkı"]},
|
|
67
|
+
{"ru": "пра́здник", "tr": ["bayram", "kutlama", "tatil günü"]},
|
|
68
|
+
{"ru": "пода́рок", "tr": ["hediye"]},
|
|
69
|
+
{"ru": "дорого́й", "tr": ["pahalı", "sevgili", "değerli"]},
|
|
70
|
+
{"ru": "дешёвый", "tr": ["ucuz"]},
|
|
71
|
+
{"ru": "бы́стрый", "tr": ["hızlı"]},
|
|
72
|
+
{"ru": "ме́дленный", "tr": ["yavaş"]},
|
|
73
|
+
{"ru": "тру́дный", "tr": ["zor"], "alt": ["сло́жный"]},
|
|
74
|
+
{"ru": "лёгкий", "tr": ["kolay", "hafif"], "alt": ["просто́й"]},
|
|
75
|
+
{"ru": "интере́сный", "tr": ["ilginç"]},
|
|
76
|
+
{"ru": "ску́чный", "tr": ["sıkıcı"]},
|
|
77
|
+
{"ru": "счастли́вый", "tr": ["mutlu", "şanslı"]},
|
|
78
|
+
{"ru": "гру́стный", "tr": ["üzgün", "hüzünlü"]},
|
|
79
|
+
{"ru": "всегда́", "tr": ["her zaman", "daima"]},
|
|
80
|
+
{"ru": "никогда́", "tr": ["asla", "hiçbir zaman"]},
|
|
81
|
+
{"ru": "иногда́", "tr": ["bazen"]},
|
|
82
|
+
{"ru": "ча́сто", "tr": ["sık sık", "sık"]},
|
|
83
|
+
{"ru": "ре́дко", "tr": ["nadiren", "seyrek"]},
|
|
84
|
+
{"ru": "покупа́ть", "tr": ["satın almak", "almak"], "alt": ["купи́ть"]},
|
|
85
|
+
{"ru": "продава́ть", "tr": ["satmak"], "alt": ["прода́ть"]},
|
|
86
|
+
{"ru": "помога́ть", "tr": ["yardım etmek"], "alt": ["помо́чь"]},
|
|
87
|
+
{"ru": "ждать", "tr": ["beklemek"], "alt": ["подожда́ть"]},
|
|
88
|
+
{"ru": "отдыха́ть", "tr": ["dinlenmek", "tatil yapmak"]},
|
|
89
|
+
{"ru": "гото́вить", "tr": ["yemek yapmak", "hazırlamak", "pişirmek"], "alt": ["пригото́вить"]},
|
|
90
|
+
{"ru": "учи́ться", "tr": ["öğrenim görmek", "okumak", "öğrenmek"]},
|
|
91
|
+
{"ru": "игра́ть", "tr": ["oynamak", "çalmak"], "alt": ["сыгра́ть"]},
|
|
92
|
+
{"ru": "звони́ть", "tr": ["telefon etmek", "aramak"], "alt": ["позвони́ть"]},
|
|
93
|
+
{"ru": "открыва́ть", "tr": ["açmak"], "alt": ["откры́ть"]},
|
|
94
|
+
{"ru": "закрыва́ть", "tr": ["kapatmak", "kapamak"], "alt": ["закры́ть"]},
|
|
95
|
+
{"ru": "ду́мать", "tr": ["düşünmek"], "alt": ["поду́мать"]},
|
|
96
|
+
{"ru": "отвеча́ть", "tr": ["cevap vermek", "yanıtlamak"], "alt": ["отве́тить"]},
|
|
97
|
+
{"ru": "спра́шивать", "tr": ["sormak"], "alt": ["спроси́ть"]},
|
|
98
|
+
{"ru": "путеше́ствовать", "tr": ["seyahat etmek", "gezmek"]},
|
|
99
|
+
{"ru": "хоте́ть", "tr": ["istemek"]},
|
|
100
|
+
{"ru": "мочь", "tr": ["yapabilmek", "-ebilmek"]},
|
|
101
|
+
{"ru": "ви́деть", "tr": ["görmek"], "alt": ["уви́деть"]}
|
|
102
|
+
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ru-flashcards",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Russian flashcards in the terminal: both directions, stress-insensitive answers, Leitner boxes so known words come back less often.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/akinakkusru-max/ru-flashcards.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/akinakkusru-max/ru-flashcards#readme",
|
|
12
|
+
"bugs": "https://github.com/akinakkusru-max/ru-flashcards/issues",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"russian",
|
|
15
|
+
"flashcards",
|
|
16
|
+
"leitner",
|
|
17
|
+
"spaced-repetition",
|
|
18
|
+
"turkish",
|
|
19
|
+
"cli",
|
|
20
|
+
"vocabulary"
|
|
21
|
+
],
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=20"
|
|
24
|
+
},
|
|
25
|
+
"bin": {
|
|
26
|
+
"ru-flashcards": "bin/ru-flashcards.mjs"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"bin",
|
|
30
|
+
"src",
|
|
31
|
+
"data",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"start": "tsx src/cli.ts",
|
|
37
|
+
"test": "vitest run",
|
|
38
|
+
"typecheck": "tsc --noEmit"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"tsx": "^4.23.15"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "^26.6.11",
|
|
45
|
+
"typescript": "^7.0.2",
|
|
46
|
+
"vitest": "^5.1.2"
|
|
47
|
+
}
|
|
48
|
+
}
|
package/src/cards.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** One card: a Russian word (stress marked with U+0301) and its accepted Turkish meanings. */
|
|
2
|
+
export interface Card {
|
|
3
|
+
ru: string;
|
|
4
|
+
tr: string[];
|
|
5
|
+
/** Other Russian words that are also right in Turkish → Russian (a synonym, the perfective partner). */
|
|
6
|
+
alt?: string[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type Direction = 'ru-tr' | 'tr-ru';
|
|
10
|
+
|
|
11
|
+
export interface Question {
|
|
12
|
+
card: Card;
|
|
13
|
+
direction: Direction;
|
|
14
|
+
/** What the learner sees. */
|
|
15
|
+
prompt: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Normalise an answer so small differences do not count as mistakes:
|
|
20
|
+
* stress marks, ё/е, extra spaces, capital letters (with Turkish I/İ rules).
|
|
21
|
+
* Hints in parentheses ("ay (takvim)") help the learner but are never required.
|
|
22
|
+
* NFD splits й and ё, so only the stress accents are removed before NFC.
|
|
23
|
+
*/
|
|
24
|
+
export function normalize(s: string): string {
|
|
25
|
+
return s
|
|
26
|
+
.replace(/\([^)]*\)/g, '')
|
|
27
|
+
.normalize('NFD')
|
|
28
|
+
.replace(/[̀́]/g, '')
|
|
29
|
+
.normalize('NFC')
|
|
30
|
+
.toLocaleLowerCase('tr')
|
|
31
|
+
.replace(/ё/g, 'е')
|
|
32
|
+
.replace(/[.!?,]/g, '')
|
|
33
|
+
.replace(/\s+/g, ' ')
|
|
34
|
+
.trim();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The answer the program expects, shown after a wrong answer. */
|
|
38
|
+
export function expected(q: Question): string {
|
|
39
|
+
return q.direction === 'ru-tr' ? q.card.tr.join(' / ') : [q.card.ru, ...(q.card.alt ?? [])].join(' / ');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function isCorrect(q: Question, answer: string): boolean {
|
|
43
|
+
const given = normalize(answer);
|
|
44
|
+
if (given === '') return false;
|
|
45
|
+
if (q.direction === 'ru-tr') return q.card.tr.some((t) => normalize(t) === given);
|
|
46
|
+
return [q.card.ru, ...(q.card.alt ?? [])].some((w) => normalize(w) === given);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Build questions, alternating direction: first Russian → Turkish, then Turkish → Russian. */
|
|
50
|
+
export function buildQuestions(cards: Card[]): Question[] {
|
|
51
|
+
return cards.map((card, i) => {
|
|
52
|
+
const direction: Direction = i % 2 === 0 ? 'ru-tr' : 'tr-ru';
|
|
53
|
+
return { card, direction, prompt: direction === 'ru-tr' ? card.ru : card.tr[0]! };
|
|
54
|
+
});
|
|
55
|
+
}
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { dirname, join, resolve } from 'node:path';
|
|
4
|
+
import { createInterface } from 'node:readline';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { buildQuestions, expected, isCorrect, type Card } from './cards.js';
|
|
7
|
+
import { boxCounts, dueCards, record, type Progress } from './leitner.js';
|
|
8
|
+
import { formatStats } from './stats.js';
|
|
9
|
+
import { speak } from './speak.js';
|
|
10
|
+
|
|
11
|
+
const argv = process.argv.slice(2);
|
|
12
|
+
const value = (name: string) => {
|
|
13
|
+
const i = argv.indexOf(`--${name}`);
|
|
14
|
+
return i >= 0 ? argv[i + 1] : undefined;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
if (argv.includes('--help')) {
|
|
18
|
+
console.log(`ru-flashcards: Russian flashcards in the terminal
|
|
19
|
+
|
|
20
|
+
ru-flashcards study up to 10 due cards
|
|
21
|
+
ru-flashcards --size 20 study up to 20
|
|
22
|
+
ru-flashcards --level a2 study the A2 deck (default: a1)
|
|
23
|
+
ru-flashcards --deck my.json use your own deck ([{"ru": "...", "tr": ["..."]}])
|
|
24
|
+
ru-flashcards --reset forget all progress
|
|
25
|
+
ru-flashcards --stats show your progress and hardest words
|
|
26
|
+
ru-flashcards --voice say each Russian word out loud (macOS)
|
|
27
|
+
|
|
28
|
+
Answers ignore stress marks, ё/е and capital letters. Type q to stop.`);
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
33
|
+
const LEVELS = ['a1', 'a2'];
|
|
34
|
+
const level = (value('level') ?? 'a1').toLowerCase();
|
|
35
|
+
if (!LEVELS.includes(level)) {
|
|
36
|
+
console.error(`Unknown level "${level}". Choose one of: ${LEVELS.join(', ')}.`);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
const deckPath = value('deck') ?? join(root, 'data', `${level}.json`);
|
|
40
|
+
const progressPath = value('progress') ?? join(homedir(), '.ru-flashcards', 'progress.json');
|
|
41
|
+
const size = Number(value('size') ?? 10);
|
|
42
|
+
const voice = argv.includes('--voice');
|
|
43
|
+
|
|
44
|
+
const deck: Card[] = JSON.parse(readFileSync(deckPath, 'utf8'));
|
|
45
|
+
let progress: Progress = !argv.includes('--reset') && existsSync(progressPath)
|
|
46
|
+
? JSON.parse(readFileSync(progressPath, 'utf8'))
|
|
47
|
+
: {};
|
|
48
|
+
|
|
49
|
+
const save = () => {
|
|
50
|
+
mkdirSync(dirname(progressPath), { recursive: true });
|
|
51
|
+
writeFileSync(progressPath, JSON.stringify(progress, null, 2) + '\n');
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
if (argv.includes('--stats')) {
|
|
55
|
+
for (const line of formatStats(deck, progress)) console.log(line);
|
|
56
|
+
console.log(`Boxes 1-5: ${boxCounts(deck, progress).join(' | ')}`);
|
|
57
|
+
process.exit(0);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const now = Date.now();
|
|
61
|
+
const questions = buildQuestions(dueCards(deck, progress, now, size));
|
|
62
|
+
if (questions.length === 0) {
|
|
63
|
+
console.log('Nothing is due right now. Come back later!');
|
|
64
|
+
console.log(`Boxes 1-5: ${boxCounts(deck, progress).join(' | ')}`);
|
|
65
|
+
process.exit(0);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Line queue: works both when a person types and when answers are piped in
|
|
69
|
+
// (piped lines can arrive before the question is asked, so none may be lost).
|
|
70
|
+
const rl = createInterface({ input: process.stdin, terminal: false });
|
|
71
|
+
const lines: string[] = [];
|
|
72
|
+
const waiting: ((line: string | null) => void)[] = [];
|
|
73
|
+
let closed = false;
|
|
74
|
+
rl.on('line', (line) => (waiting.length ? waiting.shift()!(line) : lines.push(line)));
|
|
75
|
+
rl.on('close', () => {
|
|
76
|
+
closed = true;
|
|
77
|
+
while (waiting.length) waiting.shift()!(null);
|
|
78
|
+
});
|
|
79
|
+
const ask = (prompt: string): Promise<string | null> => {
|
|
80
|
+
process.stdout.write(prompt);
|
|
81
|
+
if (lines.length) return Promise.resolve(lines.shift()!);
|
|
82
|
+
if (closed) return Promise.resolve(null);
|
|
83
|
+
return new Promise((r) => waiting.push(r));
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
let right = 0;
|
|
87
|
+
let asked = 0;
|
|
88
|
+
console.log(`${questions.length} cards. Type q to stop.\n`);
|
|
89
|
+
|
|
90
|
+
for (const q of questions) {
|
|
91
|
+
const label = q.direction === 'ru-tr' ? 'RU → TR' : 'TR → RU';
|
|
92
|
+
if (voice && q.direction === 'ru-tr') speak(q.card.ru); // hear it before answering
|
|
93
|
+
const answer = await ask(`[${label}] ${q.prompt} > `);
|
|
94
|
+
if (answer === null) break; // input closed
|
|
95
|
+
if (!process.stdin.isTTY) process.stdout.write(answer + '\n'); // echo piped answers
|
|
96
|
+
if (answer.trim().toLowerCase() === 'q') break;
|
|
97
|
+
asked++;
|
|
98
|
+
const ok = isCorrect(q, answer);
|
|
99
|
+
if (ok) right++;
|
|
100
|
+
console.log(ok ? ' ✓ correct' : ` ✗ answer: ${expected(q)}`);
|
|
101
|
+
if (voice && q.direction === 'tr-ru') speak(q.card.ru); // hear the right answer
|
|
102
|
+
progress = record(progress, q.card, ok, now);
|
|
103
|
+
save();
|
|
104
|
+
}
|
|
105
|
+
rl.close();
|
|
106
|
+
|
|
107
|
+
console.log(`\nScore: ${right}/${asked}`);
|
|
108
|
+
console.log(`Boxes 1-5: ${boxCounts(deck, progress).join(' | ')}`);
|
|
109
|
+
console.log('');
|
|
110
|
+
for (const line of formatStats(deck, progress)) console.log(line);
|
package/src/leitner.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Card } from './cards.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Leitner boxes: every card starts in box 1. A right answer moves it up one box,
|
|
5
|
+
* a wrong answer sends it back to box 1. Higher boxes wait longer before the
|
|
6
|
+
* card is shown again.
|
|
7
|
+
*/
|
|
8
|
+
export const INTERVAL_DAYS = [0, 0, 1, 3, 7, 14] as const; // index = box (1..5)
|
|
9
|
+
export const MAX_BOX = 5;
|
|
10
|
+
const DAY = 24 * 60 * 60 * 1000;
|
|
11
|
+
|
|
12
|
+
export interface CardState {
|
|
13
|
+
box: number;
|
|
14
|
+
/** When the card is due again (ms since epoch). */
|
|
15
|
+
due: number;
|
|
16
|
+
/** All-time answer counts. Optional so progress files from older versions still load. */
|
|
17
|
+
right?: number;
|
|
18
|
+
wrong?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Progress per card, keyed by the Russian word. */
|
|
22
|
+
export type Progress = Record<string, CardState>;
|
|
23
|
+
|
|
24
|
+
export function stateOf(progress: Progress, card: Card): CardState {
|
|
25
|
+
return progress[card.ru] ?? { box: 1, due: 0 };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Cards due now, lowest box first (the ones you know least), at most `limit`. */
|
|
29
|
+
export function dueCards(cards: Card[], progress: Progress, now: number, limit: number): Card[] {
|
|
30
|
+
return cards
|
|
31
|
+
.map((card, index) => ({ card, index, s: stateOf(progress, card) }))
|
|
32
|
+
.filter((x) => x.s.due <= now)
|
|
33
|
+
.sort((a, b) => a.s.box - b.s.box || a.index - b.index)
|
|
34
|
+
.slice(0, limit)
|
|
35
|
+
.map((x) => x.card);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Return new progress after one answer; the input object is not changed. */
|
|
39
|
+
export function record(progress: Progress, card: Card, correct: boolean, now: number): Progress {
|
|
40
|
+
const prev = stateOf(progress, card);
|
|
41
|
+
const box = correct ? Math.min(prev.box + 1, MAX_BOX) : 1;
|
|
42
|
+
return {
|
|
43
|
+
...progress,
|
|
44
|
+
[card.ru]: {
|
|
45
|
+
box,
|
|
46
|
+
due: now + INTERVAL_DAYS[box]! * DAY,
|
|
47
|
+
right: (prev.right ?? 0) + (correct ? 1 : 0),
|
|
48
|
+
wrong: (prev.wrong ?? 0) + (correct ? 0 : 1),
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** How many cards sit in each box, for the summary. */
|
|
54
|
+
export function boxCounts(cards: Card[], progress: Progress): number[] {
|
|
55
|
+
const counts = new Array(MAX_BOX + 1).fill(0) as number[];
|
|
56
|
+
for (const c of cards) counts[stateOf(progress, c).box]!++;
|
|
57
|
+
return counts.slice(1);
|
|
58
|
+
}
|
package/src/speak.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
|
|
3
|
+
/** Arguments for macOS `say`: stress marks removed (NFD → drop U+0301 → NFC keeps й and ё). */
|
|
4
|
+
export function sayArgs(word: string, voice = 'Milena'): string[] {
|
|
5
|
+
const plain = word.normalize('NFD').replace(/́/g, '').normalize('NFC');
|
|
6
|
+
return ['-v', voice, plain];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
let broken = false;
|
|
10
|
+
|
|
11
|
+
/** Say a Russian word out loud without waiting. On failure, warn once and stay quiet. */
|
|
12
|
+
export function speak(word: string, voice?: string): void {
|
|
13
|
+
if (broken) return;
|
|
14
|
+
if (process.platform !== 'darwin') {
|
|
15
|
+
broken = true;
|
|
16
|
+
console.log(' (voice works only on macOS)');
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const child = spawn('say', sayArgs(word, voice), { stdio: 'ignore' });
|
|
20
|
+
child.on('error', () => {
|
|
21
|
+
broken = true;
|
|
22
|
+
console.log(' (could not run "say"; voice turned off)');
|
|
23
|
+
});
|
|
24
|
+
}
|
package/src/stats.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Card } from './cards.js';
|
|
2
|
+
import { stateOf, type Progress } from './leitner.js';
|
|
3
|
+
|
|
4
|
+
export interface HardCard {
|
|
5
|
+
card: Card;
|
|
6
|
+
right: number;
|
|
7
|
+
wrong: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The cards you miss most: most wrong answers first; on a tie, the lower
|
|
12
|
+
* success rate first. Cards never answered wrong are not listed.
|
|
13
|
+
*/
|
|
14
|
+
export function hardest(cards: Card[], progress: Progress, limit = 5): HardCard[] {
|
|
15
|
+
return cards
|
|
16
|
+
.map((card) => {
|
|
17
|
+
const s = stateOf(progress, card);
|
|
18
|
+
return { card, right: s.right ?? 0, wrong: s.wrong ?? 0 };
|
|
19
|
+
})
|
|
20
|
+
.filter((x) => x.wrong > 0)
|
|
21
|
+
.sort((a, b) => b.wrong - a.wrong || a.right / (a.right + a.wrong) - b.right / (b.right + b.wrong))
|
|
22
|
+
.slice(0, limit);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface Summary {
|
|
26
|
+
/** Cards answered at least once. */
|
|
27
|
+
studied: number;
|
|
28
|
+
total: number;
|
|
29
|
+
answers: number;
|
|
30
|
+
/** Share of right answers, 0..1; null before the first answer. */
|
|
31
|
+
accuracy: number | null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function summary(cards: Card[], progress: Progress): Summary {
|
|
35
|
+
let studied = 0;
|
|
36
|
+
let right = 0;
|
|
37
|
+
let wrong = 0;
|
|
38
|
+
for (const c of cards) {
|
|
39
|
+
const s = stateOf(progress, c);
|
|
40
|
+
const r = s.right ?? 0;
|
|
41
|
+
const w = s.wrong ?? 0;
|
|
42
|
+
if (r + w > 0) studied++;
|
|
43
|
+
right += r;
|
|
44
|
+
wrong += w;
|
|
45
|
+
}
|
|
46
|
+
const answers = right + wrong;
|
|
47
|
+
return { studied, total: cards.length, answers, accuracy: answers ? right / answers : null };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Lines for the terminal. */
|
|
51
|
+
export function formatStats(cards: Card[], progress: Progress): string[] {
|
|
52
|
+
const s = summary(cards, progress);
|
|
53
|
+
const lines = [
|
|
54
|
+
`Studied: ${s.studied}/${s.total} words, ${s.answers} answers` +
|
|
55
|
+
(s.accuracy === null ? '' : `, ${Math.round(s.accuracy * 100)}% right`),
|
|
56
|
+
];
|
|
57
|
+
const hard = hardest(cards, progress);
|
|
58
|
+
if (hard.length) {
|
|
59
|
+
lines.push('Hardest words:');
|
|
60
|
+
hard.forEach((h, i) => lines.push(` ${i + 1}. ${h.card.ru} = ${h.card.tr[0]} (${h.wrong} wrong, ${h.right} right)`));
|
|
61
|
+
}
|
|
62
|
+
return lines;
|
|
63
|
+
}
|