lib/search: query readings for xrefs
This commit is contained in:
@@ -3,6 +3,12 @@ class WordSearchXrefEntry {
|
||||
/// The ID of the entry that this entry cross-references to.
|
||||
final int entryId;
|
||||
|
||||
/// The base word of the cross-referenced entry.
|
||||
final String baseWord;
|
||||
|
||||
/// The furigana of the cross-referenced entry, if any.
|
||||
final String? furigana;
|
||||
|
||||
/// Whether the entryId was ambiguous during the creation of the
|
||||
/// database (and hence might be incorrect).
|
||||
final bool ambiguous;
|
||||
@@ -10,16 +16,22 @@ class WordSearchXrefEntry {
|
||||
const WordSearchXrefEntry({
|
||||
required this.entryId,
|
||||
required this.ambiguous,
|
||||
required this.baseWord,
|
||||
required this.furigana,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'entryId': entryId,
|
||||
'ambiguous': ambiguous,
|
||||
'baseWord': baseWord,
|
||||
'furigana': furigana,
|
||||
};
|
||||
|
||||
factory WordSearchXrefEntry.fromJson(Map<String, dynamic> json) =>
|
||||
WordSearchXrefEntry(
|
||||
entryId: json['entryId'] as int,
|
||||
ambiguous: json['ambiguous'] as bool,
|
||||
baseWord: json['baseWord'] as String,
|
||||
furigana: json['furigana'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -94,10 +94,29 @@ Future<List<WordSearchResult>?> searchWordWithDbConnection(
|
||||
|
||||
late final List<Map<String, Object?>> senseAntonyms;
|
||||
final Future<List<Map<String, Object?>>> senseAntonyms_query =
|
||||
connection.query(
|
||||
'JMdict_SenseAntonym',
|
||||
where: 'senseId IN (${senseIds.join(',')})',
|
||||
);
|
||||
connection.rawQuery("""
|
||||
SELECT
|
||||
JMdict_SenseAntonym.senseId,
|
||||
JMdict_SenseAntonym.ambiguous,
|
||||
JMdict_SenseAntonym.xrefEntryId,
|
||||
JMdict_KanjiElementDistinct.reading AS kanji,
|
||||
JMdict_ReadingElementDistinct.reading AS reading
|
||||
FROM JMdict_SenseAntonym
|
||||
LEFT JOIN
|
||||
(SELECT entryId, reading FROM JMdict_KanjiElement GROUP BY entryId HAVING MIN(orderNum))
|
||||
AS JMdict_KanjiElementDistinct
|
||||
ON JMdict_SenseAntonym.xrefEntryId = JMdict_KanjiElementDistinct.entryId
|
||||
LEFT JOIN
|
||||
(SELECT entryId, reading FROM JMdict_ReadingElement GROUP BY entryId HAVING MIN(orderNum))
|
||||
AS JMdict_ReadingElementDistinct
|
||||
ON JMdict_SenseAntonym.xrefEntryId = JMdict_ReadingElementDistinct.entryId
|
||||
WHERE senseId IN (${senseIds.join(',')})
|
||||
ORDER BY
|
||||
JMdict_SenseAntonym.senseId,
|
||||
JMdict_SenseAntonym.xrefEntryId,
|
||||
JMdict_KanjiElementDistinct.reading,
|
||||
JMdict_ReadingElementDistinct.reading
|
||||
""");
|
||||
|
||||
late final List<Map<String, Object?>> senseDialects;
|
||||
final Future<List<Map<String, Object?>>> senseDialects_query =
|
||||
@@ -160,10 +179,29 @@ Future<List<WordSearchResult>?> searchWordWithDbConnection(
|
||||
|
||||
late final List<Map<String, Object?>> senseSeeAlsos;
|
||||
final Future<List<Map<String, Object?>>> senseSeeAlsos_query =
|
||||
connection.query(
|
||||
'JMdict_SenseSeeAlso',
|
||||
where: 'senseId IN (${senseIds.join(',')})',
|
||||
);
|
||||
connection.rawQuery("""
|
||||
SELECT
|
||||
JMdict_SenseSeeAlso.senseId,
|
||||
JMdict_SenseSeeAlso.ambiguous,
|
||||
JMdict_SenseSeeAlso.xrefEntryId,
|
||||
JMdict_KanjiElementDistinct.reading AS kanji,
|
||||
JMdict_ReadingElementDistinct.reading AS reading
|
||||
FROM JMdict_SenseSeeAlso
|
||||
LEFT JOIN
|
||||
(SELECT entryId, reading FROM JMdict_KanjiElement GROUP BY entryId HAVING MIN(orderNum))
|
||||
AS JMdict_KanjiElementDistinct
|
||||
ON JMdict_SenseSeeAlso.xrefEntryId = JMdict_KanjiElementDistinct.entryId
|
||||
LEFT JOIN
|
||||
(SELECT entryId, reading FROM JMdict_ReadingElement GROUP BY entryId HAVING MIN(orderNum))
|
||||
AS JMdict_ReadingElementDistinct
|
||||
ON JMdict_SenseSeeAlso.xrefEntryId = JMdict_ReadingElementDistinct.entryId
|
||||
WHERE senseId IN (${senseIds.join(',')})
|
||||
ORDER BY
|
||||
JMdict_SenseSeeAlso.senseId,
|
||||
JMdict_SenseSeeAlso.xrefEntryId,
|
||||
JMdict_KanjiElementDistinct.reading,
|
||||
JMdict_ReadingElementDistinct.reading
|
||||
""");
|
||||
|
||||
late final List<Map<String, Object?>> exampleSentences;
|
||||
final Future<List<Map<String, Object?>>> exampleSentences_query =
|
||||
@@ -493,12 +531,20 @@ List<WordSearchSense> _regroup_senses({
|
||||
seeAlso: seeAlsos
|
||||
.map((e) => WordSearchXrefEntry(
|
||||
entryId: e['xrefEntryId'] as int,
|
||||
baseWord: (e['kanji'] ?? e['reading']) as String,
|
||||
furigana: (e['kanji'] != null) ?
|
||||
(e['reading'] as String) :
|
||||
null,
|
||||
ambiguous: e['ambiguous'] == 1,
|
||||
))
|
||||
.toList(),
|
||||
antonyms: antonyms
|
||||
.map((e) => WordSearchXrefEntry(
|
||||
entryId: e['xrefEntryId'] as int,
|
||||
baseWord: (e['kanji'] ?? e['reading']) as String,
|
||||
furigana: (e['kanji'] != null) ?
|
||||
(e['reading'] as String) :
|
||||
null,
|
||||
ambiguous: e['ambiguous'] == 1,
|
||||
))
|
||||
.toList(),
|
||||
|
||||
Reference in New Issue
Block a user