jmdict: embed element type (k/r) into elementId

This commit is contained in:
2026-04-08 19:05:02 +09:00
parent 114febbe02
commit 5d26b41524
5 changed files with 18 additions and 26 deletions

View File

@@ -109,7 +109,7 @@ List<Entry> parseJMDictData(XmlElement root) {
orderNum < 100,
'Entry $entryId has more than 100 readings, which will break the elementId generation logic.',
);
final elementId = entryId * 100 + orderNum;
final elementId = 1_000_000_000 + entryId * 100 + orderNum;
final rePri = getPriorityValues(rEle, 're');
final readingDoesNotMatchKanji = rEle

View File

@@ -74,7 +74,7 @@ String _filterFTSSensitiveCharacters(String word) {
JOIN "$tableName" USING ("elementId")
JOIN "JMdict_EntryScore" USING ("elementId")
WHERE "${tableName}FTS"."reading" MATCH ? || '*'
AND "JMdict_EntryScore"."type" = '${tableName == JMdictTableNames.kanjiElement ? 'k' : 'r'}'
AND "JMdict_EntryScore"."elementId" ${tableName == JMdictTableNames.kanjiElement ? '<' : '>='} 1000000000
),
non_fts_results AS (
SELECT DISTINCT
@@ -86,7 +86,7 @@ String _filterFTSSensitiveCharacters(String word) {
JOIN "JMdict_EntryScore" USING ("elementId")
WHERE "reading" LIKE '%' || ? || '%'
AND "$tableName"."entryId" NOT IN (SELECT "entryId" FROM "fts_results")
AND "JMdict_EntryScore"."type" = '${tableName == JMdictTableNames.kanjiElement ? 'k' : 'r'}'
AND "JMdict_EntryScore"."elementId" ${tableName == JMdictTableNames.kanjiElement ? '<' : '>='} 1000000000
)
SELECT ${countOnly ? 'COUNT(DISTINCT "entryId") AS count' : '"entryId", MAX("score") AS "score"'}