Rename definitions db column to cedict_definitions
This commit is contained in:
parent
c7bd51408a
commit
2c11a3563f
@ -29,7 +29,9 @@ fun main() {
|
||||
zhuyin TEXT NOT NULL,
|
||||
searchable_pinyin TEXT NOT NULL,
|
||||
searchable_pinyin_with_tone_numbers TEXT NOT NULL,
|
||||
definitions JSON NOT NULL,
|
||||
cedict_definitions JSON NOT NULL,
|
||||
lac_definitions JSON NOT NULL,
|
||||
moe_definitions JSON NOT NULL,
|
||||
character_count INTEGER NOT NULL,
|
||||
CONSTRAINT character_count_gte CHECK(character_count > 0)
|
||||
);
|
||||
@ -51,7 +53,7 @@ fun main() {
|
||||
|
||||
val insertStatement =
|
||||
connection.prepareStatement(
|
||||
"INSERT OR IGNORE INTO cedict(traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, searchable_pinyin, searchable_pinyin_with_tone_numbers, definitions, character_count) VALUES(?,?,?,?,?,?,?,?,?)"
|
||||
"INSERT OR IGNORE INTO cedict(traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, searchable_pinyin, searchable_pinyin_with_tone_numbers, cedict_definitions, lac_definitions, moe_definitions, character_count) VALUES(?,?,?,?,?,?,?,?,?,?,?)"
|
||||
)
|
||||
for (entry in cedictEntries) {
|
||||
try {
|
||||
@ -101,7 +103,21 @@ fun main() {
|
||||
entry.definitions.map { it.glosses }
|
||||
)
|
||||
)
|
||||
insertStatement.setInt(9, entry.traditional.length)
|
||||
insertStatement.setString(
|
||||
9,
|
||||
Json.encodeToString(
|
||||
ListSerializer(String.serializer()),
|
||||
emptyList()
|
||||
)
|
||||
)
|
||||
insertStatement.setString(
|
||||
10,
|
||||
Json.encodeToString(
|
||||
ListSerializer(String.serializer()),
|
||||
emptyList()
|
||||
)
|
||||
)
|
||||
insertStatement.setInt(11, entry.traditional.length)
|
||||
} catch (_: Exception) {
|
||||
// no-op
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class SqliteDictionary(private val connection: Connection) : Dictionary {
|
||||
private val searchSimplifiedPreparedStatement: PreparedStatement by lazy {
|
||||
connection.prepareStatement(
|
||||
"""
|
||||
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, definitions
|
||||
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions
|
||||
FROM cedict
|
||||
WHERE simplified GLOB ?
|
||||
ORDER BY character_count ASC
|
||||
@ -38,7 +38,7 @@ class SqliteDictionary(private val connection: Connection) : Dictionary {
|
||||
private val searchTraditionalPreparedStatement: PreparedStatement by lazy {
|
||||
connection.prepareStatement(
|
||||
"""
|
||||
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, definitions
|
||||
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions
|
||||
FROM cedict
|
||||
WHERE traditional GLOB ?
|
||||
ORDER BY character_count ASC
|
||||
@ -49,7 +49,7 @@ class SqliteDictionary(private val connection: Connection) : Dictionary {
|
||||
private val searchPinyinPreparedStatement: PreparedStatement by lazy {
|
||||
connection.prepareStatement(
|
||||
"""
|
||||
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, definitions
|
||||
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions
|
||||
FROM cedict
|
||||
WHERE searchable_pinyin GLOB ?
|
||||
OR searchable_pinyin_with_tone_numbers GLOB ?
|
||||
@ -60,7 +60,7 @@ class SqliteDictionary(private val connection: Connection) : Dictionary {
|
||||
|
||||
private val searchSegments = """
|
||||
WITH cte(id, segment) AS (VALUES ?)
|
||||
SELECT cedict.traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, definitions
|
||||
SELECT cedict.traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions
|
||||
FROM cedict INNER JOIN cte
|
||||
ON cte.segment = cedict.traditional OR cte.segment = cedict.simplified
|
||||
ORDER BY cte.id
|
||||
@ -69,7 +69,7 @@ class SqliteDictionary(private val connection: Connection) : Dictionary {
|
||||
private val findWordsContaining: PreparedStatement by lazy {
|
||||
connection.prepareStatement(
|
||||
"""
|
||||
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, definitions
|
||||
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions
|
||||
FROM cedict
|
||||
WHERE traditional LIKE ?
|
||||
ORDER BY character_count ASC
|
||||
@ -79,7 +79,7 @@ class SqliteDictionary(private val connection: Connection) : Dictionary {
|
||||
|
||||
private val findCharacters = """
|
||||
WITH cte(id, character) AS (VALUES ?)
|
||||
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, definitions
|
||||
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions
|
||||
FROM cedict INNER JOIN cte
|
||||
ON cte.character = cedict.traditional OR cte.character = cedict.simplified
|
||||
ORDER BY cte.id
|
||||
|
Loading…
Reference in New Issue
Block a user