Store tones for each entry
This commit is contained in:
parent
9f60c4c9b2
commit
849bdb8c1a
@ -42,6 +42,7 @@ fun main() {
|
||||
cross_straits_definitions JSON NOT NULL,
|
||||
moe_definitions JSON NOT NULL,
|
||||
character_count INTEGER NOT NULL,
|
||||
tones JSON NOT NULL,
|
||||
CONSTRAINT character_count_gte CHECK(character_count > 0)
|
||||
);
|
||||
""".trimIndent()
|
||||
@ -62,7 +63,7 @@ fun main() {
|
||||
|
||||
val insertStatement =
|
||||
connection.prepareStatement(
|
||||
"INSERT OR IGNORE INTO entry(traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, searchable_pinyin, searchable_pinyin_with_tone_numbers, cedict_definitions, cross_straits_definitions, moe_definitions, character_count) VALUES(?,?,?,?,?,?,?,?,?,?,?)"
|
||||
"INSERT OR IGNORE INTO entry(traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, searchable_pinyin, searchable_pinyin_with_tone_numbers, cedict_definitions, cross_straits_definitions, moe_definitions, character_count, tones) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)"
|
||||
)
|
||||
cedictEntries.groupBy {
|
||||
"${it.traditional}${it.pinyinSyllables.joinToString(
|
||||
@ -135,6 +136,13 @@ fun main() {
|
||||
)
|
||||
)
|
||||
insertStatement.setInt(11, entry.traditional.length)
|
||||
insertStatement.setString(
|
||||
12,
|
||||
Json.encodeToString(
|
||||
ListSerializer(Int.serializer()),
|
||||
entry.pinyinSyllables.map { it.tone.toInt() }
|
||||
)
|
||||
)
|
||||
} catch (_: Exception) {
|
||||
// no-op
|
||||
}
|
||||
@ -156,7 +164,7 @@ fun main() {
|
||||
private fun createCrossStraitsEntries(connection: Connection) {
|
||||
val insertStatement =
|
||||
connection.prepareStatement(
|
||||
"INSERT OR IGNORE INTO entry(traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, searchable_pinyin, searchable_pinyin_with_tone_numbers, cedict_definitions, cross_straits_definitions, moe_definitions, character_count) VALUES(?,?,?,?,?,?,?,?,?,?,?)"
|
||||
"INSERT OR IGNORE INTO entry(traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, searchable_pinyin, searchable_pinyin_with_tone_numbers, cedict_definitions, cross_straits_definitions, moe_definitions, character_count, tones) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)"
|
||||
)
|
||||
|
||||
val updateStatement = connection.prepareStatement(
|
||||
@ -238,6 +246,13 @@ private fun createCrossStraitsEntries(connection: Connection) {
|
||||
)
|
||||
)
|
||||
insertStatement.setInt(11, entry.traditional.length)
|
||||
insertStatement.setString(
|
||||
12,
|
||||
Json.encodeToString(
|
||||
ListSerializer(Int.serializer()),
|
||||
pronunciation.map { it.tone.toInt() }
|
||||
)
|
||||
)
|
||||
} catch (_: Exception) {
|
||||
// no-op
|
||||
}
|
||||
@ -256,7 +271,7 @@ private fun createCrossStraitsEntries(connection: Connection) {
|
||||
private fun createMoedictEntries(connection: Connection) {
|
||||
val insertStatement =
|
||||
connection.prepareStatement(
|
||||
"INSERT OR IGNORE INTO entry(traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, searchable_pinyin, searchable_pinyin_with_tone_numbers, cedict_definitions, cross_straits_definitions, moe_definitions, character_count) VALUES(?,?,?,?,?,?,?,?,?,?,?)"
|
||||
"INSERT OR IGNORE INTO entry(traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, searchable_pinyin, searchable_pinyin_with_tone_numbers, cedict_definitions, cross_straits_definitions, moe_definitions, character_count, tones) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)"
|
||||
)
|
||||
|
||||
val updateStatement = connection.prepareStatement(
|
||||
@ -356,6 +371,13 @@ private fun createMoedictEntries(connection: Connection) {
|
||||
)
|
||||
)
|
||||
insertStatement.setInt(11, traditional.length)
|
||||
insertStatement.setString(
|
||||
12,
|
||||
Json.encodeToString(
|
||||
ListSerializer(Int.serializer()),
|
||||
pronunciation.map { it.tone.toInt() }
|
||||
)
|
||||
)
|
||||
} catch (_: Exception) {
|
||||
// no-op
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user