New Features #1

Open
marvinelsen wants to merge 95 commits from develop into main
2 changed files with 9 additions and 7 deletions
Showing only changes of commit b22e436f8b - Show all commits

View File

@ -31,21 +31,21 @@ class SqliteDictionary(private val connection: Connection) : Dictionary {
.posData(SegmentPosDatas.define())
private val searchSimplifiedSql = """
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions, cross_straits_definitions, moe_definitions
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions, cross_straits_definitions, moe_definitions, tones
FROM entry
WHERE simplified GLOB ?
ORDER BY character_count ASC
""".trimIndent()
private val searchTraditionalSql = """
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions, cross_straits_definitions, moe_definitions
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions, cross_straits_definitions, moe_definitions, tones
FROM entry
WHERE traditional GLOB ?
ORDER BY character_count ASC
""".trimIndent()
private val searchPinyinSql = """
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions, cross_straits_definitions, moe_definitions
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions, cross_straits_definitions, moe_definitions, tones
FROM entry
WHERE searchable_pinyin GLOB ?
OR searchable_pinyin_with_tone_numbers GLOB ?
@ -54,21 +54,21 @@ class SqliteDictionary(private val connection: Connection) : Dictionary {
private val searchSegmentsSql = """
WITH cte(id, segment) AS (VALUES ?)
SELECT entry.traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions, cross_straits_definitions, moe_definitions
SELECT entry.traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions, cross_straits_definitions, moe_definitions, tones
FROM entry INNER JOIN cte
ON cte.segment = entry.traditional OR cte.segment = entry.simplified
ORDER BY cte.id
""".trimIndent()
private val findWordsBeginningSql = """
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions, cross_straits_definitions, moe_definitions
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions, cross_straits_definitions, moe_definitions, tones
FROM entry
WHERE traditional GLOB ?
ORDER BY character_count ASC
""".trimIndent()
private val findWordsContainingSql = """
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions, cross_straits_definitions, moe_definitions
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions, cross_straits_definitions, moe_definitions, tones
FROM entry
WHERE traditional LIKE ?
ORDER BY character_count ASC
@ -76,7 +76,7 @@ class SqliteDictionary(private val connection: Connection) : Dictionary {
private val findCharactersSql = """
WITH cte(id, character, pinyin) AS (VALUES ?)
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions, cross_straits_definitions, moe_definitions
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions, cross_straits_definitions, moe_definitions, tones
FROM entry INNER JOIN cte
ON cte.character = entry.traditional
WHERE cte.pinyin = entry.pinyin_with_tone_numbers
@ -214,6 +214,7 @@ private fun ResultSet.toDictionaryEntry() = DictionaryEntry(
cedictDefinitions = Json.decodeFromString(this.getString(6)),
crossStraitsDefinitions = Json.decodeFromString(this.getString(7)),
moedictDefinitions = Json.decodeFromString(this.getString(8)),
tones = Json.decodeFromString(this.getString(9)),
)
private fun ResultSet.toListOfDictionaryEntries() = buildList {

View File

@ -12,4 +12,5 @@ data class DictionaryEntry(
val cedictDefinitions: List<List<String>>,
val crossStraitsDefinitions: List<CrossStraitsDefinition>,
val moedictDefinitions: List<MoedictDefinition>,
val tones: List<Int>,
)