lib: format

This commit is contained in:
2025-05-16 21:06:19 +02:00
parent 84ae7eca9e
commit 3f267b78d3
16 changed files with 360 additions and 96 deletions

View File

@@ -197,7 +197,8 @@ class Sense extends SQLWritable {
'orderNum': orderNum,
};
bool get isEmpty => antonyms.isEmpty &&
bool get isEmpty =>
antonyms.isEmpty &&
dialects.isEmpty &&
fields.isEmpty &&
info.isEmpty &&

View File

@@ -128,7 +128,8 @@ Future<void> seedJMDictData(List<Entry> entries, Database db) async {
for (final e in entries) {
for (final s in e.senses) {
b.insert(JMdictTableNames.sense, s.sqlValue..addAll({'entryId': e.entryId}));
b.insert(
JMdictTableNames.sense, s.sqlValue..addAll({'entryId': e.entryId}));
for (final d in s.dialects) {
b.insert(
JMdictTableNames.senseDialect,
@@ -136,7 +137,8 @@ Future<void> seedJMDictData(List<Entry> entries, Database db) async {
);
}
for (final f in s.fields) {
b.insert(JMdictTableNames.senseField, {'senseId': s.senseId, 'field': f});
b.insert(
JMdictTableNames.senseField, {'senseId': s.senseId, 'field': f});
}
for (final i in s.info) {
b.insert(JMdictTableNames.senseInfo, {'senseId': s.senseId, 'info': i});

View File

@@ -3,7 +3,7 @@ abstract class SQLWritable {
const SQLWritable();
/// Returns a map of the object's properties and their values.
///
///
/// Note that there might be properties in the object which is meant to be
/// inserted into a different table. These properties will/should be excluded
/// from this map.

View File

@@ -14,8 +14,7 @@ class CreateDb extends Command {
addLibsqliteArg(argParser);
argParser.addFlag(
'wal',
help:
'''Whether to use Write-Ahead Logging (WAL) mode.
help: '''Whether to use Write-Ahead Logging (WAL) mode.
This is recommended for better performance, but may not be used with
the readonly NixOS store.

View File

@@ -1,4 +1,3 @@
import 'dart:convert';
import 'dart:io';

View File

@@ -1861,11 +1861,12 @@ const Map<int, Map<int, List<String>>> JOUYOU_KANJI_BY_GRADE_AND_STROKE_COUNT =
},
};
final Map<int, List<String>> JOUYOU_KANJI_BY_GRADES = JOUYOU_KANJI_BY_GRADE_AND_STROKE_COUNT.entries
.expand((entry) => entry.value.entries)
.map((entry) => MapEntry(entry.key, entry.value))
.fold<Map<int, List<String>>>(
{},
(acc, entry) => acc
..putIfAbsent(entry.key, () => [])
..update(entry.key, (value) => value..addAll(entry.value)));
final Map<int, List<String>> JOUYOU_KANJI_BY_GRADES =
JOUYOU_KANJI_BY_GRADE_AND_STROKE_COUNT.entries
.expand((entry) => entry.value.entries)
.map((entry) => MapEntry(entry.key, entry.value))
.fold<Map<int, List<String>>>(
{},
(acc, entry) => acc
..putIfAbsent(entry.key, () => [])
..update(entry.key, (value) => value..addAll(entry.value)));

View File

@@ -1,12 +1,211 @@
const Map<int, List<String>> RADICALS = {
1: ['', '', '', '', '', ''],
2: ['', '', '', '', '𠆢', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '𠂉'],
3: ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '广', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''],
4: ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''],
5: ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''],
6: ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '西'],
7: ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''],
2: [
'',
'',
'',
'',
'𠆢',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'𠂉'
],
3: [
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'广',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
''
],
4: [
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
''
],
5: [
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
''
],
6: [
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'西'
],
7: [
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
''
],
8: ['', '', '', '', '', '', '', '', '', '', '', ''],
9: ['', '', '', '', '', '', '', '', '', '', ''],
10: ['', '', '', '', '', '', '', '', '', ''],

View File

@@ -24,8 +24,7 @@ enum JMdictDialect {
required this.description,
});
static JMdictDialect fromId(String id) =>
JMdictDialect.values.firstWhere(
static JMdictDialect fromId(String id) => JMdictDialect.values.firstWhere(
(e) => e.id == id,
orElse: () => throw Exception('Unknown id: $id'),
);

View File

@@ -107,8 +107,7 @@ enum JMdictField {
required this.description,
});
static JMdictField fromId(String id) =>
JMdictField.values.firstWhere(
static JMdictField fromId(String id) => JMdictField.values.firstWhere(
(e) => e.id == id,
orElse: () => throw Exception('Unknown id: $id'),
);

View File

@@ -18,8 +18,7 @@ enum JMdictKanjiInfo {
required this.description,
});
static JMdictKanjiInfo fromId(String id) =>
JMdictKanjiInfo.values.firstWhere(
static JMdictKanjiInfo fromId(String id) => JMdictKanjiInfo.values.firstWhere(
(e) => e.id == id,
orElse: () => throw Exception('Unknown id: $id'),
);

View File

@@ -79,8 +79,7 @@ enum JMdictMisc {
required this.description,
});
static JMdictMisc fromId(String id) =>
JMdictMisc.values.firstWhere(
static JMdictMisc fromId(String id) => JMdictMisc.values.firstWhere(
(e) => e.id == id,
orElse: () => throw Exception('Unknown id: $id'),
);

View File

@@ -7,14 +7,18 @@ enum JMdictPOS {
adjIx(id: 'adj-ix', description: 'adjective (keiyoushi) - yoi/ii class'),
adjKari(id: 'adj-kari', description: '\'kari\' adjective (archaic)'),
adjKu(id: 'adj-ku', description: '\'ku\' adjective (archaic)'),
adjNa(id: 'adj-na', description: 'adjectival nouns or quasi-adjectives (keiyodoshi)'),
adjNa(
id: 'adj-na',
description: 'adjectival nouns or quasi-adjectives (keiyodoshi)'),
adjNari(id: 'adj-nari', description: 'archaic/formal form of na-adjective'),
adjNo(id: 'adj-no', description: 'nouns which may take the genitive case particle ''no'''),
adjNo(
id: 'adj-no',
description: 'nouns which may take the genitive case particle ' 'no' ''),
adjPn(id: 'adj-pn', description: 'pre-noun adjectival (rentaishi)'),
adjShiku(id: 'adj-shiku', description: '\'shiku\' adjective (archaic)'),
adjT(id: 'adj-t', description: '\'taru\' adjective'),
adv(id: 'adv', description: 'adverb (fukushi)'),
advTo(id: 'adv-to', description: 'adverb taking the ''to'' particle'),
advTo(id: 'adv-to', description: 'adverb taking the ' 'to' ' particle'),
aux(id: 'aux', description: 'auxiliary'),
auxAdj(id: 'aux-adj', description: 'auxiliary adjective'),
auxV(id: 'aux-v', description: 'auxiliary verb'),
@@ -38,62 +42,123 @@ enum JMdictPOS {
vUnspec(id: 'v-unspec', description: 'verb unspecified'),
v1(id: 'v1', description: 'Ichidan verb'),
v1S(id: 'v1-s', description: 'Ichidan verb - kureru special class'),
v2aS(id: 'v2a-s', description: 'Nidan verb with ''u'' ending (archaic)'),
v2bK(id: 'v2b-k', description: 'Nidan verb (upper class) with ''bu'' ending (archaic)'),
v2bS(id: 'v2b-s', description: 'Nidan verb (lower class) with ''bu'' ending (archaic)'),
v2dK(id: 'v2d-k', description: 'Nidan verb (upper class) with ''dzu'' ending (archaic)'),
v2dS(id: 'v2d-s', description: 'Nidan verb (lower class) with ''dzu'' ending (archaic)'),
v2gK(id: 'v2g-k', description: 'Nidan verb (upper class) with ''gu'' ending (archaic)'),
v2gS(id: 'v2g-s', description: 'Nidan verb (lower class) with ''gu'' ending (archaic)'),
v2hK(id: 'v2h-k', description: 'Nidan verb (upper class) with ''hu/fu'' ending (archaic)'),
v2hS(id: 'v2h-s', description: 'Nidan verb (lower class) with ''hu/fu'' ending (archaic)'),
v2kK(id: 'v2k-k', description: 'Nidan verb (upper class) with ''ku'' ending (archaic)'),
v2kS(id: 'v2k-s', description: 'Nidan verb (lower class) with ''ku'' ending (archaic)'),
v2mK(id: 'v2m-k', description: 'Nidan verb (upper class) with ''mu'' ending (archaic)'),
v2mS(id: 'v2m-s', description: 'Nidan verb (lower class) with ''mu'' ending (archaic)'),
v2nS(id: 'v2n-s', description: 'Nidan verb (lower class) with ''nu'' ending (archaic)'),
v2rK(id: 'v2r-k', description: 'Nidan verb (upper class) with ''ru'' ending (archaic)'),
v2rS(id: 'v2r-s', description: 'Nidan verb (lower class) with ''ru'' ending (archaic)'),
v2sS(id: 'v2s-s', description: 'Nidan verb (lower class) with ''su'' ending (archaic)'),
v2tK(id: 'v2t-k', description: 'Nidan verb (upper class) with ''tsu'' ending (archaic)'),
v2tS(id: 'v2t-s', description: 'Nidan verb (lower class) with ''tsu'' ending (archaic)'),
v2wS(id: 'v2w-s', description: 'Nidan verb (lower class) with ''u'' ending and ''we'' conjugation (archaic)'),
v2yK(id: 'v2y-k', description: 'Nidan verb (upper class) with ''yu'' ending (archaic)'),
v2yS(id: 'v2y-s', description: 'Nidan verb (lower class) with ''yu'' ending (archaic)'),
v2zS(id: 'v2z-s', description: 'Nidan verb (lower class) with ''zu'' ending (archaic)'),
v4b(id: 'v4b', description: 'Yodan verb with ''bu'' ending (archaic)'),
v4g(id: 'v4g', description: 'Yodan verb with ''gu'' ending (archaic)'),
v4h(id: 'v4h', description: 'Yodan verb with ''hu/fu'' ending (archaic)'),
v4k(id: 'v4k', description: 'Yodan verb with ''ku'' ending (archaic)'),
v4m(id: 'v4m', description: 'Yodan verb with ''mu'' ending (archaic)'),
v4n(id: 'v4n', description: 'Yodan verb with ''nu'' ending (archaic)'),
v4r(id: 'v4r', description: 'Yodan verb with ''ru'' ending (archaic)'),
v4s(id: 'v4s', description: 'Yodan verb with ''su'' ending (archaic)'),
v4t(id: 'v4t', description: 'Yodan verb with ''tsu'' ending (archaic)'),
v2aS(id: 'v2a-s', description: 'Nidan verb with ' 'u' ' ending (archaic)'),
v2bK(
id: 'v2b-k',
description: 'Nidan verb (upper class) with ' 'bu' ' ending (archaic)'),
v2bS(
id: 'v2b-s',
description: 'Nidan verb (lower class) with ' 'bu' ' ending (archaic)'),
v2dK(
id: 'v2d-k',
description: 'Nidan verb (upper class) with ' 'dzu' ' ending (archaic)'),
v2dS(
id: 'v2d-s',
description: 'Nidan verb (lower class) with ' 'dzu' ' ending (archaic)'),
v2gK(
id: 'v2g-k',
description: 'Nidan verb (upper class) with ' 'gu' ' ending (archaic)'),
v2gS(
id: 'v2g-s',
description: 'Nidan verb (lower class) with ' 'gu' ' ending (archaic)'),
v2hK(
id: 'v2h-k',
description:
'Nidan verb (upper class) with ' 'hu/fu' ' ending (archaic)'),
v2hS(
id: 'v2h-s',
description:
'Nidan verb (lower class) with ' 'hu/fu' ' ending (archaic)'),
v2kK(
id: 'v2k-k',
description: 'Nidan verb (upper class) with ' 'ku' ' ending (archaic)'),
v2kS(
id: 'v2k-s',
description: 'Nidan verb (lower class) with ' 'ku' ' ending (archaic)'),
v2mK(
id: 'v2m-k',
description: 'Nidan verb (upper class) with ' 'mu' ' ending (archaic)'),
v2mS(
id: 'v2m-s',
description: 'Nidan verb (lower class) with ' 'mu' ' ending (archaic)'),
v2nS(
id: 'v2n-s',
description: 'Nidan verb (lower class) with ' 'nu' ' ending (archaic)'),
v2rK(
id: 'v2r-k',
description: 'Nidan verb (upper class) with ' 'ru' ' ending (archaic)'),
v2rS(
id: 'v2r-s',
description: 'Nidan verb (lower class) with ' 'ru' ' ending (archaic)'),
v2sS(
id: 'v2s-s',
description: 'Nidan verb (lower class) with ' 'su' ' ending (archaic)'),
v2tK(
id: 'v2t-k',
description: 'Nidan verb (upper class) with ' 'tsu' ' ending (archaic)'),
v2tS(
id: 'v2t-s',
description: 'Nidan verb (lower class) with ' 'tsu' ' ending (archaic)'),
v2wS(
id: 'v2w-s',
description: 'Nidan verb (lower class) with '
'u'
' ending and '
'we'
' conjugation (archaic)'),
v2yK(
id: 'v2y-k',
description: 'Nidan verb (upper class) with ' 'yu' ' ending (archaic)'),
v2yS(
id: 'v2y-s',
description: 'Nidan verb (lower class) with ' 'yu' ' ending (archaic)'),
v2zS(
id: 'v2z-s',
description: 'Nidan verb (lower class) with ' 'zu' ' ending (archaic)'),
v4b(id: 'v4b', description: 'Yodan verb with ' 'bu' ' ending (archaic)'),
v4g(id: 'v4g', description: 'Yodan verb with ' 'gu' ' ending (archaic)'),
v4h(id: 'v4h', description: 'Yodan verb with ' 'hu/fu' ' ending (archaic)'),
v4k(id: 'v4k', description: 'Yodan verb with ' 'ku' ' ending (archaic)'),
v4m(id: 'v4m', description: 'Yodan verb with ' 'mu' ' ending (archaic)'),
v4n(id: 'v4n', description: 'Yodan verb with ' 'nu' ' ending (archaic)'),
v4r(id: 'v4r', description: 'Yodan verb with ' 'ru' ' ending (archaic)'),
v4s(id: 'v4s', description: 'Yodan verb with ' 'su' ' ending (archaic)'),
v4t(id: 'v4t', description: 'Yodan verb with ' 'tsu' ' ending (archaic)'),
v5aru(id: 'v5aru', description: 'Godan verb - -aru special class'),
v5b(id: 'v5b', description: 'Godan verb with ''bu'' ending'),
v5g(id: 'v5g', description: 'Godan verb with ''gu'' ending'),
v5k(id: 'v5k', description: 'Godan verb with ''ku'' ending'),
v5b(id: 'v5b', description: 'Godan verb with ' 'bu' ' ending'),
v5g(id: 'v5g', description: 'Godan verb with ' 'gu' ' ending'),
v5k(id: 'v5k', description: 'Godan verb with ' 'ku' ' ending'),
v5kS(id: 'v5k-s', description: 'Godan verb - Iku/Yuku special class'),
v5m(id: 'v5m', description: 'Godan verb with ''mu'' ending'),
v5n(id: 'v5n', description: 'Godan verb with ''nu'' ending'),
v5r(id: 'v5r', description: 'Godan verb with ''ru'' ending'),
v5rI(id: 'v5r-i', description: 'Godan verb with ''ru'' ending (irregular verb)'),
v5s(id: 'v5s', description: 'Godan verb with ''su'' ending'),
v5t(id: 'v5t', description: 'Godan verb with ''tsu'' ending'),
v5u(id: 'v5u', description: 'Godan verb with ''u'' ending'),
v5uS(id: 'v5u-s', description: 'Godan verb with ''u'' ending (special class)'),
v5uru(id: 'v5uru', description: 'Godan verb - Uru old class verb (old form of Eru)'),
v5m(id: 'v5m', description: 'Godan verb with ' 'mu' ' ending'),
v5n(id: 'v5n', description: 'Godan verb with ' 'nu' ' ending'),
v5r(id: 'v5r', description: 'Godan verb with ' 'ru' ' ending'),
v5rI(
id: 'v5r-i',
description: 'Godan verb with ' 'ru' ' ending (irregular verb)'),
v5s(id: 'v5s', description: 'Godan verb with ' 'su' ' ending'),
v5t(id: 'v5t', description: 'Godan verb with ' 'tsu' ' ending'),
v5u(id: 'v5u', description: 'Godan verb with ' 'u' ' ending'),
v5uS(
id: 'v5u-s',
description: 'Godan verb with ' 'u' ' ending (special class)'),
v5uru(
id: 'v5uru',
description: 'Godan verb - Uru old class verb (old form of Eru)'),
vi(id: 'vi', description: 'intransitive verb'),
vk(id: 'vk', description: 'Kuru verb - special class'),
vn(id: 'vn', description: 'irregular nu verb'),
vr(id: 'vr', description: 'irregular ru verb, plain form ends with -ri'),
vs(id: 'vs', description: 'noun or participle which takes the aux. verb suru'),
vs(
id: 'vs',
description: 'noun or participle which takes the aux. verb suru'),
vsC(id: 'vs-c', description: 'suru verb - precursor to the modern suru'),
vsI(id: 'vs-i', description: 'suru verb - included'),
vsS(id: 'vs-s', description: 'suru verb - special class'),
vt(id: 'vt', description: 'transitive verb'),
vz(id: 'vz', description: 'Ichidan verb - zuru verb (alternative form of -jiru verbs)');
vz(
id: 'vz',
description:
'Ichidan verb - zuru verb (alternative form of -jiru verbs)');
final String id;
final String description;
@@ -103,8 +168,7 @@ enum JMdictPOS {
required this.description,
});
static JMdictPOS fromId(String id) =>
JMdictPOS.values.firstWhere(
static JMdictPOS fromId(String id) => JMdictPOS.values.firstWhere(
(e) => e.id == id,
orElse: () => throw Exception('Unknown id: $id'),
);

View File

@@ -51,8 +51,9 @@ List<WordSearchResult> regroupWordSearchResults({
.where((element) => element['entryId'] == scoredEntryId.entryId)
.toList();
final List<Map<String, Object?>> entryJlptTags =
jlptTags.where((element) => element['entryId'] == scoredEntryId.entryId).toList();
final List<Map<String, Object?>> entryJlptTags = jlptTags
.where((element) => element['entryId'] == scoredEntryId.entryId)
.toList();
final jlptLevel = entryJlptTags
.map((e) => JlptLevel.fromString(e['jlptLevel'] as String?))
@@ -62,8 +63,9 @@ List<WordSearchResult> regroupWordSearchResults({
final isCommon = commonEntryIds.contains(scoredEntryId.entryId);
final List<Map<String, Object?>> entrySenses =
senses.where((element) => element['entryId'] == scoredEntryId.entryId).toList();
final List<Map<String, Object?>> entrySenses = senses
.where((element) => element['entryId'] == scoredEntryId.entryId)
.toList();
final GroupedWordResult entryReadingElementsGrouped = _regroup_words(
entryId: scoredEntryId.entryId,

View File

@@ -45,7 +45,8 @@ Future<List<WordSearchResult>?> searchWordWithDbConnection(
return [];
}
final LinearWordQueryData linearWordQueryData = await fetchLinearWordQueryData(
final LinearWordQueryData linearWordQueryData =
await fetchLinearWordQueryData(
connection,
entryIds.map((e) => e.entryId).toList(),
);

View File

@@ -289,15 +289,16 @@ extension on DateTime {
}
String get japaneseWeekdayPrefix => [
'',
'',
'',
'',
'',
'',
'',
][weekday - 1];
'',
'',
'',
'',
'',
'',
'',
][weekday - 1];
/// Returns the date in Japanese format.
String japaneseDate({bool showWeekday = false}) => '$month月$day日' + (showWeekday ? '$japaneseWeekdayPrefix' : '');
String japaneseDate({bool showWeekday = false}) =>
'$month月$day日' + (showWeekday ? '$japaneseWeekdayPrefix' : '');
}

View File

@@ -30,7 +30,6 @@ const String rawHiraganaRegex = r'\p{Script=Hiragana}';
/// Remember to turn on the unicode flag when making a new RegExp.
const String rawKanjiRegex = r'[\u3400-\u4DB5\u4E00-\u9FCB\uF900-\uFA6A]';
final RegExp cjkRegex = RegExp(rawCJKRegex, unicode: true);
final RegExp katakanaRegex = RegExp(rawKatakanaRegex, unicode: true);
final RegExp hiraganaRegex = RegExp(rawHiraganaRegex, unicode: true);