lib/search: continue work on jmdict search
This commit is contained in:
@@ -25,7 +25,7 @@ Future<List<WordSearchResult>?> searchWordWithDbConnection(
|
||||
where: 'kana LIKE ?',
|
||||
whereArgs: ['%$word%'],
|
||||
))
|
||||
.map((row) => row['id'] as int)
|
||||
.map((row) => row['entryId'] as int)
|
||||
.toList();
|
||||
} else {
|
||||
matches = (await connection.query(
|
||||
@@ -33,7 +33,7 @@ Future<List<WordSearchResult>?> searchWordWithDbConnection(
|
||||
where: 'english LIKE ?',
|
||||
whereArgs: ['%$word%'],
|
||||
))
|
||||
.map((row) => row['id'] as int)
|
||||
.map((row) => row['entryId'] as int)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ Future<List<WordSearchResult>?> searchWordWithDbConnection(
|
||||
final Future<List<int>> senseIds_query = connection
|
||||
.query(
|
||||
'JMdict_Sense',
|
||||
where: 'id IN (${matches.join(',')})',
|
||||
where: 'entryId IN (${matches.join(',')})',
|
||||
)
|
||||
.then((rows) => rows.map((row) => row['id'] as int).toList());
|
||||
|
||||
@@ -53,17 +53,17 @@ Future<List<WordSearchResult>?> searchWordWithDbConnection(
|
||||
final Future<List<Map<String, Object?>>> readingElements_query =
|
||||
connection.query(
|
||||
'JMdict_ReadingElement',
|
||||
where: 'entry_id IN (${matches.join(',')})',
|
||||
where: 'entryId IN (${matches.join(',')})',
|
||||
);
|
||||
|
||||
late final List<Map<String, Object?>> kanjiElements;
|
||||
final Future<List<Map<String, Object?>>> kanjiElements_query =
|
||||
connection.query(
|
||||
'JMdict_KanjiElement',
|
||||
where: 'entry_id IN (${matches.join(',')})',
|
||||
where: 'entryId IN (${matches.join(',')})',
|
||||
);
|
||||
|
||||
Future.wait([
|
||||
await Future.wait([
|
||||
senseIds_query.then((value) => senseIds = value),
|
||||
readingElements_query.then((value) => readingElements = value),
|
||||
kanjiElements_query.then((value) => kanjiElements = value),
|
||||
@@ -73,33 +73,139 @@ Future<List<WordSearchResult>?> searchWordWithDbConnection(
|
||||
print(readingElements);
|
||||
print(kanjiElements);
|
||||
|
||||
// JMdict_EntryByEnglish
|
||||
// JMdict_EntryByKana
|
||||
//
|
||||
// JMdict_ExampleSentence
|
||||
// JMdict_InfoDialect
|
||||
// JMdict_InfoField
|
||||
// JMdict_InfoKanji
|
||||
// JMdict_InfoMisc
|
||||
// JMdict_InfoPOS
|
||||
// JMdict_InfoReading
|
||||
// JMdict_KanjiElement
|
||||
// JMdict_KanjiElementInfo
|
||||
// JMdict_ReadingElement
|
||||
// JMdict_ReadingElementInfo
|
||||
// JMdict_ReadingElementRestriction
|
||||
// JMdict_Sense
|
||||
// JMdict_SenseAntonym
|
||||
// JMdict_SenseDialect
|
||||
// JMdict_SenseField
|
||||
// JMdict_SenseGlossary
|
||||
// JMdict_SenseInfo
|
||||
// JMdict_SenseLanguageSource
|
||||
// JMdict_SenseMisc
|
||||
// JMdict_SensePOS
|
||||
// JMdict_SenseRestrictedToKanji
|
||||
// JMdict_SenseRestrictedToReading
|
||||
// JMdict_SenseSeeAlso
|
||||
// Sense queries
|
||||
|
||||
late final List<Map<String, Object?>> senseAntonyms;
|
||||
final Future<List<Map<String, Object?>>> senseAntonyms_query =
|
||||
connection.query(
|
||||
'JMdict_SenseAntonym',
|
||||
where: 'entryId IN (${senseIds.join(',')})',
|
||||
);
|
||||
|
||||
late final List<Map<String, Object?>> senseDialects;
|
||||
final Future<List<Map<String, Object?>>> senseDialects_query =
|
||||
connection.query(
|
||||
'JMdict_SenseDialect',
|
||||
where: 'entryId IN (${senseIds.join(',')})',
|
||||
);
|
||||
|
||||
late final List<Map<String, Object?>> senseFields;
|
||||
final Future<List<Map<String, Object?>>> senseFields_query = connection.query(
|
||||
'JMdict_SenseField',
|
||||
where: 'entryId IN (${senseIds.join(',')})',
|
||||
);
|
||||
|
||||
late final List<Map<String, Object?>> senseGlossaries;
|
||||
final Future<List<Map<String, Object?>>> senseGlossaries_query =
|
||||
connection.query(
|
||||
'JMdict_SenseGlossary',
|
||||
where: 'entryId IN (${senseIds.join(',')})',
|
||||
);
|
||||
|
||||
late final List<Map<String, Object?>> senseInfos;
|
||||
final Future<List<Map<String, Object?>>> senseInfos_query = connection.query(
|
||||
'JMdict_SenseInfo',
|
||||
where: 'entryId IN (${senseIds.join(',')})',
|
||||
);
|
||||
|
||||
late final List<Map<String, Object?>> senseLanguageSources;
|
||||
final Future<List<Map<String, Object?>>> senseLanguageSources_query =
|
||||
connection.query(
|
||||
'JMdict_SenseLanguageSource',
|
||||
where: 'entryId IN (${senseIds.join(',')})',
|
||||
);
|
||||
|
||||
late final List<Map<String, Object?>> senseMiscs;
|
||||
final Future<List<Map<String, Object?>>> senseMiscs_query = connection.query(
|
||||
'JMdict_SenseMisc',
|
||||
where: 'entryId IN (${senseIds.join(',')})',
|
||||
);
|
||||
|
||||
late final List<Map<String, Object?>> sensePOSs;
|
||||
final Future<List<Map<String, Object?>>> sensePOSs_query = connection.query(
|
||||
'JMdict_SensePOS',
|
||||
where: 'entryId IN (${senseIds.join(',')})',
|
||||
);
|
||||
|
||||
late final List<Map<String, Object?>> senseRestrictedToKanjis;
|
||||
final Future<List<Map<String, Object?>>> senseRestrictedToKanjis_query =
|
||||
connection.query(
|
||||
'JMdict_SenseRestrictedToKanji',
|
||||
where: 'entryId IN (${senseIds.join(',')})',
|
||||
);
|
||||
|
||||
late final List<Map<String, Object?>> senseRestrictedToReadings;
|
||||
final Future<List<Map<String, Object?>>> senseRestrictedToReadings_query =
|
||||
connection.query(
|
||||
'JMdict_SenseRestrictedToReading',
|
||||
where: 'entryId IN (${senseIds.join(',')})',
|
||||
);
|
||||
|
||||
late final List<Map<String, Object?>> senseSeeAlsos;
|
||||
final Future<List<Map<String, Object?>>> senseSeeAlsos_query =
|
||||
connection.query(
|
||||
'JMdict_SenseSeeAlso',
|
||||
where: 'entryId IN (${senseIds.join(',')})',
|
||||
);
|
||||
|
||||
late final List<Map<String, Object?>> exampleSentences;
|
||||
final Future<List<Map<String, Object?>>> exampleSentences_query =
|
||||
connection.query(
|
||||
'JMdict_ExampleSentence',
|
||||
where: 'entryId IN (${senseIds.join(',')})',
|
||||
);
|
||||
|
||||
// Reading queries
|
||||
|
||||
final readingIds =
|
||||
readingElements.map((element) => (element['entryId'] as int, element['reading'] as String)).toList();
|
||||
|
||||
late final List<Map<String, Object?>> readingElementInfos;
|
||||
final Future<List<Map<String, Object?>>> readingElementInfos_query =
|
||||
connection.query(
|
||||
'JMdict_ReadingElementInfo',
|
||||
where: 'entryId IN (${readingIds.join(',')})',
|
||||
);
|
||||
|
||||
late final List<Map<String, Object?>> readingElementRestrictions;
|
||||
final Future<List<Map<String, Object?>>> readingElementRestrictions_query =
|
||||
connection.query(
|
||||
'JMdict_ReadingElementRestriction',
|
||||
where: 'entryId IN (${readingIds.join(',')})',
|
||||
);
|
||||
|
||||
// Kanji queries
|
||||
|
||||
final kanjiIds =
|
||||
kanjiElements.map((element) => (element['entryId'] as int, element['reading'] as String)).toList();
|
||||
|
||||
late final List<Map<String, Object?>> kanjiElementInfos;
|
||||
final Future<List<Map<String, Object?>>> kanjiElementInfos_query =
|
||||
connection.query(
|
||||
'JMdict_KanjiElementInfo',
|
||||
where: 'entryId IN (${kanjiIds.join(',')})',
|
||||
);
|
||||
|
||||
await Future.wait([
|
||||
senseAntonyms_query.then((value) => senseAntonyms = value),
|
||||
senseDialects_query.then((value) => senseDialects = value),
|
||||
senseFields_query.then((value) => senseFields = value),
|
||||
senseGlossaries_query.then((value) => senseGlossaries = value),
|
||||
senseInfos_query.then((value) => senseInfos = value),
|
||||
senseLanguageSources_query.then((value) => senseLanguageSources = value),
|
||||
senseMiscs_query.then((value) => senseMiscs = value),
|
||||
sensePOSs_query.then((value) => sensePOSs = value),
|
||||
senseRestrictedToKanjis_query
|
||||
.then((value) => senseRestrictedToKanjis = value),
|
||||
senseRestrictedToReadings_query
|
||||
.then((value) => senseRestrictedToReadings = value),
|
||||
senseSeeAlsos_query.then((value) => senseSeeAlsos = value),
|
||||
exampleSentences_query.then((value) => exampleSentences = value),
|
||||
readingElementInfos_query.then((value) => readingElementInfos = value),
|
||||
readingElementRestrictions_query
|
||||
.then((value) => readingElementRestrictions = value),
|
||||
kanjiElementInfos_query.then((value) => kanjiElementInfos = value),
|
||||
]);
|
||||
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user