mirror of
https://github.com/h7x4/Jisho-Study-Tool.git
synced 2024-12-21 21:47:29 +01:00
Add storage entities
This commit is contained in:
parent
8811cef864
commit
a0c608ccca
13
lib/models/storage/common.dart
Normal file
13
lib/models/storage/common.dart
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import 'package:objectbox/objectbox.dart';
|
||||||
|
import 'package:unofficial_jisho_api/api.dart' as jisho;
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
class ExampleSentencePiece {
|
||||||
|
int id = 0;
|
||||||
|
String? lifted;
|
||||||
|
String unlifted;
|
||||||
|
|
||||||
|
ExampleSentencePiece.fromJishoObject(jisho.ExampleSentencePiece object) :
|
||||||
|
lifted = object.lifted,
|
||||||
|
unlifted = object.unlifted;
|
||||||
|
}
|
36
lib/models/storage/example.dart
Normal file
36
lib/models/storage/example.dart
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import 'package:objectbox/objectbox.dart';
|
||||||
|
import 'package:unofficial_jisho_api/api.dart' as jisho;
|
||||||
|
|
||||||
|
import 'common.dart';
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
class ExampleResultData {
|
||||||
|
String kanji;
|
||||||
|
String kana;
|
||||||
|
String english;
|
||||||
|
List<ExampleSentencePiece> pieces;
|
||||||
|
|
||||||
|
ExampleResultData.fromJishoObject(jisho.ExampleResultData object)
|
||||||
|
: kanji = object.kanji,
|
||||||
|
kana = object.kana,
|
||||||
|
english = object.english,
|
||||||
|
pieces = object.pieces
|
||||||
|
.map((p) => ExampleSentencePiece.fromJishoObject(p))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
class ExampleResults {
|
||||||
|
String query;
|
||||||
|
bool found;
|
||||||
|
String uri;
|
||||||
|
List<ExampleResultData> results;
|
||||||
|
|
||||||
|
ExampleResults.fromJishoObject(jisho.ExampleResults object)
|
||||||
|
: query = object.query,
|
||||||
|
found = object.found,
|
||||||
|
uri = object.uri,
|
||||||
|
results = object.results
|
||||||
|
.map((r) => ExampleResultData.fromJishoObject(r))
|
||||||
|
.toList();
|
||||||
|
}
|
86
lib/models/storage/kanji_result.dart
Normal file
86
lib/models/storage/kanji_result.dart
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
import 'package:objectbox/objectbox.dart';
|
||||||
|
import 'package:unofficial_jisho_api/api.dart' as jisho;
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
class YomiExample {
|
||||||
|
int id = 0;
|
||||||
|
String example;
|
||||||
|
String reading;
|
||||||
|
String meaning;
|
||||||
|
|
||||||
|
YomiExample.fromJishoObject(jisho.YomiExample object)
|
||||||
|
: example = object.example,
|
||||||
|
reading = object.reading,
|
||||||
|
meaning = object.meaning;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
class Radical {
|
||||||
|
int id = 0;
|
||||||
|
String symbol;
|
||||||
|
List<String> forms;
|
||||||
|
String meaning;
|
||||||
|
|
||||||
|
Radical.fromJishoObject(jisho.Radical object)
|
||||||
|
: symbol = object.symbol,
|
||||||
|
forms = object.forms,
|
||||||
|
meaning = object.meaning;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
class KanjiResult {
|
||||||
|
int id = 0;
|
||||||
|
String query;
|
||||||
|
bool found;
|
||||||
|
KanjiResultData? data;
|
||||||
|
|
||||||
|
KanjiResult.fromJishoObject(jisho.KanjiResult object)
|
||||||
|
: query = object.query,
|
||||||
|
found = object.found,
|
||||||
|
data = (object.data == null)
|
||||||
|
? null
|
||||||
|
: KanjiResultData.fromJishoObject(object.data!);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
class KanjiResultData {
|
||||||
|
int id = 0;
|
||||||
|
String? taughtIn;
|
||||||
|
String? jlptLevel;
|
||||||
|
int? newspaperFrequencyRank;
|
||||||
|
int strokeCount;
|
||||||
|
String meaning;
|
||||||
|
List<String> kunyomi;
|
||||||
|
List<String> onyomi;
|
||||||
|
List<YomiExample> kunyomiExamples;
|
||||||
|
List<YomiExample> onyomiExamples;
|
||||||
|
Radical? radical;
|
||||||
|
List<String> parts;
|
||||||
|
String strokeOrderDiagramUri;
|
||||||
|
String strokeOrderSvgUri;
|
||||||
|
String strokeOrderGifUri;
|
||||||
|
String uri;
|
||||||
|
|
||||||
|
KanjiResultData.fromJishoObject(jisho.KanjiResultData object)
|
||||||
|
: taughtIn = object.taughtIn,
|
||||||
|
jlptLevel = object.jlptLevel,
|
||||||
|
newspaperFrequencyRank = object.newspaperFrequencyRank,
|
||||||
|
strokeCount = object.strokeCount,
|
||||||
|
meaning = object.meaning,
|
||||||
|
kunyomi = object.kunyomi,
|
||||||
|
onyomi = object.onyomi,
|
||||||
|
kunyomiExamples = object.kunyomiExamples
|
||||||
|
.map((k) => YomiExample.fromJishoObject(k))
|
||||||
|
.toList(),
|
||||||
|
onyomiExamples = object.onyomiExamples
|
||||||
|
.map((o) => YomiExample.fromJishoObject(o))
|
||||||
|
.toList(),
|
||||||
|
radical = (object.radical == null)
|
||||||
|
? null
|
||||||
|
: Radical.fromJishoObject(object.radical!),
|
||||||
|
parts = object.parts,
|
||||||
|
strokeOrderDiagramUri = object.strokeOrderDiagramUri,
|
||||||
|
strokeOrderSvgUri = object.strokeOrderSvgUri,
|
||||||
|
strokeOrderGifUri = object.strokeOrderGifUri,
|
||||||
|
uri = object.uri;
|
||||||
|
}
|
101
lib/models/storage/scrape_result.dart
Normal file
101
lib/models/storage/scrape_result.dart
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
import 'package:objectbox/objectbox.dart';
|
||||||
|
import 'package:unofficial_jisho_api/api.dart' as jisho;
|
||||||
|
|
||||||
|
import 'common.dart';
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
class PhraseScrapeSentence {
|
||||||
|
int id = 0;
|
||||||
|
String english;
|
||||||
|
String japanese;
|
||||||
|
List<ExampleSentencePiece> pieces;
|
||||||
|
|
||||||
|
PhraseScrapeSentence.fromJishoObject(jisho.PhraseScrapeSentence object)
|
||||||
|
: english = object.english,
|
||||||
|
japanese = object.japanese,
|
||||||
|
pieces = object.pieces
|
||||||
|
.map((p) => ExampleSentencePiece.fromJishoObject(p))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
class PhraseScrapeMeaning {
|
||||||
|
int id = 0;
|
||||||
|
List<String> seeAlsoTerms;
|
||||||
|
List<PhraseScrapeSentence> sentences;
|
||||||
|
String definition;
|
||||||
|
List<String> supplemental;
|
||||||
|
String? definitionAbstract;
|
||||||
|
List<String> tags;
|
||||||
|
|
||||||
|
PhraseScrapeMeaning.fromJishoObject(jisho.PhraseScrapeMeaning object)
|
||||||
|
: seeAlsoTerms = object.seeAlsoTerms,
|
||||||
|
sentences = object.sentences
|
||||||
|
.map((s) => PhraseScrapeSentence.fromJishoObject(s))
|
||||||
|
.toList(),
|
||||||
|
definition = object.definition,
|
||||||
|
supplemental = object.supplemental,
|
||||||
|
definitionAbstract = object.definitionAbstract,
|
||||||
|
tags = object.tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
class KanjiKanaPair {
|
||||||
|
int id = 0;
|
||||||
|
String kanji;
|
||||||
|
String? kana;
|
||||||
|
|
||||||
|
KanjiKanaPair.fromJishoObject(jisho.KanjiKanaPair object)
|
||||||
|
: kanji = object.kanji,
|
||||||
|
kana = object.kana;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
class PhrasePageScrapeResult {
|
||||||
|
int id = 0;
|
||||||
|
bool found;
|
||||||
|
String query;
|
||||||
|
PhrasePageScrapeResultData? data;
|
||||||
|
|
||||||
|
PhrasePageScrapeResult.fromJishoObject(jisho.PhrasePageScrapeResult object)
|
||||||
|
: found = object.found,
|
||||||
|
query = object.query,
|
||||||
|
data = (object.data == null)
|
||||||
|
? null
|
||||||
|
: PhrasePageScrapeResultData.fromJishoObject(object.data!);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
class AudioFile {
|
||||||
|
int id = 0;
|
||||||
|
String uri;
|
||||||
|
String mimetype;
|
||||||
|
|
||||||
|
AudioFile.fromJishoObject(jisho.AudioFile object)
|
||||||
|
: uri = object.uri,
|
||||||
|
mimetype = object.mimetype;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
class PhrasePageScrapeResultData {
|
||||||
|
int id = 0;
|
||||||
|
String uri;
|
||||||
|
List<String> tags;
|
||||||
|
List<PhraseScrapeMeaning> meanings;
|
||||||
|
List<KanjiKanaPair> otherForms;
|
||||||
|
List<AudioFile> audio;
|
||||||
|
List<String> notes;
|
||||||
|
|
||||||
|
PhrasePageScrapeResultData.fromJishoObject(
|
||||||
|
jisho.PhrasePageScrapeResultData object,
|
||||||
|
) : uri = object.uri,
|
||||||
|
tags = object.tags,
|
||||||
|
meanings = object.meanings
|
||||||
|
.map((m) => PhraseScrapeMeaning.fromJishoObject(m))
|
||||||
|
.toList(),
|
||||||
|
otherForms = object.otherForms
|
||||||
|
.map((f) => KanjiKanaPair.fromJishoObject(f))
|
||||||
|
.toList(),
|
||||||
|
audio = object.audio.map((a) => AudioFile.fromJishoObject(a)).toList(),
|
||||||
|
notes = object.notes;
|
||||||
|
}
|
@ -1,72 +1,126 @@
|
|||||||
// import 'package:objectbox/objectbox.dart';
|
import 'package:objectbox/objectbox.dart';
|
||||||
// import 'package:unofficial_jisho_api/api.dart' as jisho;
|
import 'package:unofficial_jisho_api/api.dart' as jisho;
|
||||||
|
|
||||||
// @Entity()
|
@Entity()
|
||||||
// class SearchResult {
|
class SearchResult {
|
||||||
// int id = 0;
|
int id = 0;
|
||||||
// final meta = ToOne<JishoResultMeta>();
|
final JishoResultMeta meta;
|
||||||
// final data = ToMany<JishoResult>();
|
final ToMany<JishoResult> data = ToMany<JishoResult>();
|
||||||
|
|
||||||
// // SearchResult(JishoAPIResult result) {
|
SearchResult.fromJishoObject(final jisho.JishoAPIResult object)
|
||||||
// // this.data = result.data;
|
: meta = JishoResultMeta.fromJishoObject(object.meta) {
|
||||||
// // this.meta = result.meta;
|
data.addAll(
|
||||||
// // }
|
object.data
|
||||||
|
?.map((r) => JishoResult.fromJishoObject(r)) ??
|
||||||
|
<JishoResult>[],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// // JishoAPIResult toJishoAPIResult() {
|
@Entity()
|
||||||
// // return JishoAPIResult(meta: this.meta, data: this.data);
|
class JishoResultMeta {
|
||||||
// // }
|
int id = 0;
|
||||||
// }
|
int status;
|
||||||
|
|
||||||
// @Entity()
|
JishoResultMeta.fromJishoObject(final jisho.JishoResultMeta object)
|
||||||
// class JishoResultMeta {
|
: status = object.status;
|
||||||
// int id = 0;
|
}
|
||||||
// int status;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Entity()
|
@Entity()
|
||||||
// class JishoResult {
|
class JishoResult {
|
||||||
// int id = 0;
|
int id = 0;
|
||||||
// final attribution = ToOne<JishoAttribution>();
|
JishoAttribution attribution;
|
||||||
// bool is_common;
|
bool? is_common;
|
||||||
// final japanese = ToMany<JishoJapaneseWord>();
|
List<JishoJapaneseWord> japanese;
|
||||||
// List<String> jlpt;
|
List<String> jlpt;
|
||||||
// final senses = ToMany<JishoWordSense>();
|
List<JishoWordSense> senses;
|
||||||
// String slug;
|
String slug;
|
||||||
// List<String> tags;
|
List<String> tags;
|
||||||
// }
|
|
||||||
|
|
||||||
// @Entity()
|
JishoResult.fromJishoObject(final jisho.JishoResult object)
|
||||||
// class JishoAttribution {
|
: attribution = JishoAttribution.fromJishoObject(object.attribution),
|
||||||
// int id = 0;
|
is_common = object.isCommon,
|
||||||
// String dbpedia;
|
japanese = object.japanese
|
||||||
// String jmdict;
|
.map((j) => JishoJapaneseWord.fromJishoObject(j))
|
||||||
// bool jmnedict;
|
.toList(),
|
||||||
// }
|
jlpt = object.jlpt,
|
||||||
|
senses = object.senses
|
||||||
|
.map((s) => JishoWordSense.fromJishoObject(s))
|
||||||
|
.toList(),
|
||||||
|
slug = object.slug,
|
||||||
|
tags = object.tags;
|
||||||
|
}
|
||||||
|
|
||||||
// @Entity()
|
@Entity()
|
||||||
// class JishoJapaneseWord {
|
class JishoAttribution {
|
||||||
// int id = 0;
|
int id = 0;
|
||||||
// String reading;
|
String? dbpedia;
|
||||||
// String word;
|
bool jmdict;
|
||||||
// }
|
bool jmnedict;
|
||||||
|
|
||||||
// @Entity()
|
JishoAttribution.fromJishoObject(final jisho.JishoAttribution object)
|
||||||
// class JishoWordSense {
|
: dbpedia = object.dbpedia,
|
||||||
// int id = 0;
|
jmdict = object.jmdict,
|
||||||
// List<String> antonyms;
|
jmnedict = object.jmnedict;
|
||||||
// List<String> english_definitions;
|
}
|
||||||
// List<String> info;
|
|
||||||
// final links = ToMany<JishoSenseLink>();
|
|
||||||
// List<String> parts_of_speech;
|
|
||||||
// List<String> restrictions;
|
|
||||||
// List<String> see_also;
|
|
||||||
// List<dynamic> source;
|
|
||||||
// List<String> tags;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Entity()
|
@Entity()
|
||||||
// class JishoSenseLink {
|
class JishoJapaneseWord {
|
||||||
// int id = 0;
|
int id = 0;
|
||||||
// String text;
|
String? reading;
|
||||||
// String url;
|
String? word;
|
||||||
// }
|
|
||||||
|
JishoJapaneseWord.fromJishoObject(final jisho.JishoJapaneseWord object)
|
||||||
|
: reading = object.reading,
|
||||||
|
word = object.word;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
class JishoWordSense {
|
||||||
|
int id = 0;
|
||||||
|
List<String> antonyms;
|
||||||
|
List<String> english_definitions;
|
||||||
|
List<String> info;
|
||||||
|
List<JishoSenseLink> links;
|
||||||
|
List<String> parts_of_speech;
|
||||||
|
List<String> restrictions;
|
||||||
|
List<String> see_also;
|
||||||
|
List<JishoWordSource> source;
|
||||||
|
List<String> tags;
|
||||||
|
|
||||||
|
JishoWordSense.fromJishoObject(final jisho.JishoWordSense object)
|
||||||
|
: antonyms = object.antonyms,
|
||||||
|
english_definitions = object.englishDefinitions,
|
||||||
|
info = object.info,
|
||||||
|
links =
|
||||||
|
object.links.map((l) => JishoSenseLink.fromJishoObject(l)).toList(),
|
||||||
|
parts_of_speech = object.partsOfSpeech,
|
||||||
|
restrictions = object.restrictions,
|
||||||
|
see_also = object.seeAlso,
|
||||||
|
source = object.source
|
||||||
|
.map((s) => JishoWordSource.fromJishoObject(s))
|
||||||
|
.toList(),
|
||||||
|
tags = object.tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
class JishoWordSource {
|
||||||
|
int id = 0;
|
||||||
|
String language;
|
||||||
|
String? word;
|
||||||
|
|
||||||
|
JishoWordSource.fromJishoObject(final jisho.JishoWordSource object)
|
||||||
|
: language = object.language,
|
||||||
|
word = object.word;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
class JishoSenseLink {
|
||||||
|
int id = 0;
|
||||||
|
String text;
|
||||||
|
String url;
|
||||||
|
|
||||||
|
JishoSenseLink.fromJishoObject(final jisho.JishoSenseLink object)
|
||||||
|
: text = object.text,
|
||||||
|
url = object.url;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user