diff --git a/lib/search/jmdict.dart b/lib/search/jmdict.dart index 1f9fbc5..a29a9ce 100644 --- a/lib/search/jmdict.dart +++ b/lib/search/jmdict.dart @@ -25,7 +25,7 @@ Future?> 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?> searchWordWithDbConnection( where: 'english LIKE ?', whereArgs: ['%$word%'], )) - .map((row) => row['id'] as int) + .map((row) => row['entryId'] as int) .toList(); } @@ -45,7 +45,7 @@ Future?> searchWordWithDbConnection( final Future> 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?> searchWordWithDbConnection( final Future>> readingElements_query = connection.query( 'JMdict_ReadingElement', - where: 'entry_id IN (${matches.join(',')})', + where: 'entryId IN (${matches.join(',')})', ); late final List> kanjiElements; final Future>> 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?> 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> senseAntonyms; + final Future>> senseAntonyms_query = + connection.query( + 'JMdict_SenseAntonym', + where: 'entryId IN (${senseIds.join(',')})', + ); + + late final List> senseDialects; + final Future>> senseDialects_query = + connection.query( + 'JMdict_SenseDialect', + where: 'entryId IN (${senseIds.join(',')})', + ); + + late final List> senseFields; + final Future>> senseFields_query = connection.query( + 'JMdict_SenseField', + where: 'entryId IN (${senseIds.join(',')})', + ); + + late final List> senseGlossaries; + final Future>> senseGlossaries_query = + connection.query( + 'JMdict_SenseGlossary', + where: 'entryId IN (${senseIds.join(',')})', + ); + + late final List> senseInfos; + final Future>> senseInfos_query = connection.query( + 'JMdict_SenseInfo', + where: 'entryId IN (${senseIds.join(',')})', + ); + + late final List> senseLanguageSources; + final Future>> senseLanguageSources_query = + connection.query( + 'JMdict_SenseLanguageSource', + where: 'entryId IN (${senseIds.join(',')})', + ); + + late final List> senseMiscs; + final Future>> senseMiscs_query = connection.query( + 'JMdict_SenseMisc', + where: 'entryId IN (${senseIds.join(',')})', + ); + + late final List> sensePOSs; + final Future>> sensePOSs_query = connection.query( + 'JMdict_SensePOS', + where: 'entryId IN (${senseIds.join(',')})', + ); + + late final List> senseRestrictedToKanjis; + final Future>> senseRestrictedToKanjis_query = + connection.query( + 'JMdict_SenseRestrictedToKanji', + where: 'entryId IN (${senseIds.join(',')})', + ); + + late final List> senseRestrictedToReadings; + final Future>> senseRestrictedToReadings_query = + connection.query( + 'JMdict_SenseRestrictedToReading', + where: 'entryId IN (${senseIds.join(',')})', + ); + + late final List> senseSeeAlsos; + final Future>> senseSeeAlsos_query = + connection.query( + 'JMdict_SenseSeeAlso', + where: 'entryId IN (${senseIds.join(',')})', + ); + + late final List> exampleSentences; + final Future>> 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> readingElementInfos; + final Future>> readingElementInfos_query = + connection.query( + 'JMdict_ReadingElementInfo', + where: 'entryId IN (${readingIds.join(',')})', + ); + + late final List> readingElementRestrictions; + final Future>> 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> kanjiElementInfos; + final Future>> 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(); }