feat(dictionary): characters of Chinese, Korean and Greek, written by hand; pinyin typed
Parity with Japanese's kanji and kana: - The characters' tab is named by its language (Hanzi, Hangul & Hanja, Alphabet), its groups too: HSK levels and the characters in common use (Hong Kong's grades for traditional ones); Hangul and the Hanja taught in schools; Greek's letters. Radicals for Chinese and Korean in their own forms (讠 for 言 in simplified Chinese), none for Greek. - A character's readings are named as its language names them: On and Kun, Pinyin, Eum and Hun (음, 훈); a letter means its sound and name. - How characters are written comes by language: Chinese from Make Me a Hanzi (its medians in KanjiVG's square, Arphic Public License, a data file beside the app, never in cards), the Hangul letters drawn by the curator; a Korean word is written letter by letter (닭: ㄷ ㅏ ㄺ). Words of alphabets (German, Greek) aren't written by hand. - A Chinese word's pinyin is typed in a session, tone numbers turning into marks (ni3 → nǐ); KRDict's levels (초급, 중급, 고급) tag Korean words; a Korean word's pronunciation shows in brackets ([가치]). - Smaller: Look up in the composer keeps a noun's article; the Watch filter names its level list; hints and placeholders by language. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
7070cd6bd2
commit
5479b973fc
1 changed files with 2559 additions and 230 deletions
|
|
@ -0,0 +1,52 @@
|
|||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:halkyon_learn_flutter/src/core/chinese/pinyin_input.dart';
|
||||
|
||||
void main() {
|
||||
test('tone numbers become tone marks: on a or e, on the o of ou, else on '
|
||||
'the last vowel; ü typed as v or u:; the neutral tone unmarked', () {
|
||||
expect(withToneMarks('ni3hao3'), 'nǐhǎo');
|
||||
expect(withToneMarks('xue2xi2'), 'xuéxí');
|
||||
expect(withToneMarks('dou1'), 'dōu');
|
||||
expect(withToneMarks('gui4'), 'guì');
|
||||
expect(withToneMarks('liu2'), 'liú');
|
||||
expect(withToneMarks('lv4'), 'lǜ');
|
||||
expect(withToneMarks('nu:3'), 'nǚ');
|
||||
expect(withToneMarks('ma5'), 'ma');
|
||||
expect(withToneMarks('Bei3jing1'), 'Běijīng');
|
||||
expect(withToneMarks('xuéxí'), 'xuéxí');
|
||||
});
|
||||
|
||||
test('pinyin compares with its tones, whatever its case, spaces and '
|
||||
'numbers', () {
|
||||
expect(pinyinKey('Xué xí'), 'xuéxí');
|
||||
expect(pinyinKey('xue2 xi2'), 'xuéxí');
|
||||
expect(pinyinKey("Xi1'an1"), 'xīān');
|
||||
expect(givenPinyin('xíng, háng'), {'xíng', 'háng'});
|
||||
expect(givenPinyin('xíng').contains(pinyinKey('xing2')), isTrue);
|
||||
expect(givenPinyin('xíng').contains(pinyinKey('xing1')), isFalse);
|
||||
});
|
||||
|
||||
test("pinyin is told from kana and from words' own letters", () {
|
||||
expect(isPinyin('xué xí'), isTrue);
|
||||
expect(isPinyin('shuō'), isTrue);
|
||||
expect(isPinyin('たべる'), isFalse);
|
||||
expect(isPinyin('가치'), isFalse);
|
||||
expect(isPinyin(''), isFalse);
|
||||
});
|
||||
|
||||
test('typing turns a syllable and its tone into the marked syllable, the '
|
||||
'caret where it was typed', () {
|
||||
const formatter = PinyinInputFormatter();
|
||||
final value = formatter.formatEditUpdate(
|
||||
const TextEditingValue(text: 'ni'),
|
||||
const TextEditingValue(
|
||||
text: 'ni3',
|
||||
selection: TextSelection.collapsed(offset: 3),
|
||||
),
|
||||
);
|
||||
|
||||
expect(value.text, 'nǐ');
|
||||
expect(value.selection, const TextSelection.collapsed(offset: 2));
|
||||
});
|
||||
}
|
||||
Loading…
Reference in a new issue