import 'package:jadb/_data_ingestion/sql_writable.dart'; abstract class Element extends SQLWritable { final String reading; final int? news; final int? ichi; final int? spec; final int? gai; final int? nf; const Element({ required this.reading, this.news, this.ichi, this.spec, this.gai, this.nf, }); Map get sqlValue => { 'reading': reading, 'news': news, 'ichi': ichi, 'spec': spec, 'gai': gai, 'nf': nf, }; } class KanjiElement extends Element { int orderNum; List info; KanjiElement({ this.info = const [], required this.orderNum, required String reading, int? news, int? ichi, int? spec, int? gai, int? nf, }) : super( reading: reading, news: news, ichi: ichi, spec: spec, gai: gai, nf: nf, ); @override Map get sqlValue => { ...super.sqlValue, 'orderNum': orderNum, }; } class ReadingElement extends Element { int orderNum; bool readingDoesNotMatchKanji; List info; List restrictions; ReadingElement({ required this.orderNum, required this.readingDoesNotMatchKanji, this.info = const [], this.restrictions = const [], required String reading, int? news, int? ichi, int? spec, int? gai, int? nf, }) : super( reading: reading, news: news, ichi: ichi, spec: spec, gai: gai, nf: nf, ); @override Map get sqlValue => { ...super.sqlValue, 'orderNum': orderNum, 'readingDoesNotMatchKanji': readingDoesNotMatchKanji, }; } class LanguageSource extends SQLWritable { final String language; final String? phrase; final bool fullyDescribesSense; final bool constructedFromSmallerWords; const LanguageSource({ required this.language, required this.phrase, this.fullyDescribesSense = true, this.constructedFromSmallerWords = false, }); @override Map get sqlValue => { 'language': language, 'phrase': phrase, 'fullyDescribesSense': fullyDescribesSense, 'constructedFromSmallerWords': constructedFromSmallerWords, }; } class Glossary extends SQLWritable { final String language; final String phrase; final String? type; const Glossary({ required this.language, required this.phrase, this.type, }); Map get sqlValue => { 'language': language, 'phrase': phrase, 'type': type, }; } final kanaRegex = RegExp(r'^[\p{Script=Katakana}\p{Script=Hiragana}ー]+$', unicode: true); class XRefParts { final String? kanjiRef; final String? readingRef; final int? senseOrderNum; const XRefParts({ this.kanjiRef, this.readingRef, this.senseOrderNum, }) : assert(kanjiRef != null || readingRef != null); Map toJson() => { 'kanjiRef': kanjiRef, 'readingRef': readingRef, 'senseOrderNum': senseOrderNum, }; } class XRef { final String entryId; final String reading; const XRef({ required this.entryId, required this.reading, }); } class Sense extends SQLWritable { final int senseId; final int orderNum; final List antonyms; final List dialects; final List fields; final List info; final List languageSource; final List glossary; final List misc; final List pos; final List restrictedToKanji; final List restrictedToReading; final List seeAlso; const Sense({ required this.senseId, required this.orderNum, this.antonyms = const [], this.dialects = const [], this.fields = const [], this.info = const [], this.languageSource = const [], this.glossary = const [], this.misc = const [], this.pos = const [], this.restrictedToKanji = const [], this.restrictedToReading = const [], this.seeAlso = const [], }); @override Map get sqlValue => { 'senseId': senseId, 'orderNum': orderNum, }; bool get isEmpty => antonyms.isEmpty && dialects.isEmpty && fields.isEmpty && info.isEmpty && languageSource.isEmpty && glossary.isEmpty && misc.isEmpty && pos.isEmpty && restrictedToKanji.isEmpty && restrictedToReading.isEmpty && seeAlso.isEmpty; } class Entry extends SQLWritable { final int entryId; final List kanji; final List readings; final List senses; const Entry({ required this.entryId, required this.kanji, required this.readings, required this.senses, }); Map get sqlValue => {'entryId': entryId}; }