Receive tones from database
This commit is contained in:
parent
e4f7e8ee5d
commit
b22e436f8b
@ -31,21 +31,21 @@ class SqliteDictionary(private val connection: Connection) : Dictionary {
|
|||||||
.posData(SegmentPosDatas.define())
|
.posData(SegmentPosDatas.define())
|
||||||
|
|
||||||
private val searchSimplifiedSql = """
|
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
|
FROM entry
|
||||||
WHERE simplified GLOB ?
|
WHERE simplified GLOB ?
|
||||||
ORDER BY character_count ASC
|
ORDER BY character_count ASC
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
private val searchTraditionalSql = """
|
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
|
FROM entry
|
||||||
WHERE traditional GLOB ?
|
WHERE traditional GLOB ?
|
||||||
ORDER BY character_count ASC
|
ORDER BY character_count ASC
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
private val searchPinyinSql = """
|
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
|
FROM entry
|
||||||
WHERE searchable_pinyin GLOB ?
|
WHERE searchable_pinyin GLOB ?
|
||||||
OR searchable_pinyin_with_tone_numbers GLOB ?
|
OR searchable_pinyin_with_tone_numbers GLOB ?
|
||||||
@ -54,21 +54,21 @@ class SqliteDictionary(private val connection: Connection) : Dictionary {
|
|||||||
|
|
||||||
private val searchSegmentsSql = """
|
private val searchSegmentsSql = """
|
||||||
WITH cte(id, segment) AS (VALUES ?)
|
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
|
FROM entry INNER JOIN cte
|
||||||
ON cte.segment = entry.traditional OR cte.segment = entry.simplified
|
ON cte.segment = entry.traditional OR cte.segment = entry.simplified
|
||||||
ORDER BY cte.id
|
ORDER BY cte.id
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
private val findWordsBeginningSql = """
|
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
|
FROM entry
|
||||||
WHERE traditional GLOB ?
|
WHERE traditional GLOB ?
|
||||||
ORDER BY character_count ASC
|
ORDER BY character_count ASC
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
private val findWordsContainingSql = """
|
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
|
FROM entry
|
||||||
WHERE traditional LIKE ?
|
WHERE traditional LIKE ?
|
||||||
ORDER BY character_count ASC
|
ORDER BY character_count ASC
|
||||||
@ -76,7 +76,7 @@ class SqliteDictionary(private val connection: Connection) : Dictionary {
|
|||||||
|
|
||||||
private val findCharactersSql = """
|
private val findCharactersSql = """
|
||||||
WITH cte(id, character, pinyin) AS (VALUES ?)
|
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
|
FROM entry INNER JOIN cte
|
||||||
ON cte.character = entry.traditional
|
ON cte.character = entry.traditional
|
||||||
WHERE cte.pinyin = entry.pinyin_with_tone_numbers
|
WHERE cte.pinyin = entry.pinyin_with_tone_numbers
|
||||||
@ -214,6 +214,7 @@ private fun ResultSet.toDictionaryEntry() = DictionaryEntry(
|
|||||||
cedictDefinitions = Json.decodeFromString(this.getString(6)),
|
cedictDefinitions = Json.decodeFromString(this.getString(6)),
|
||||||
crossStraitsDefinitions = Json.decodeFromString(this.getString(7)),
|
crossStraitsDefinitions = Json.decodeFromString(this.getString(7)),
|
||||||
moedictDefinitions = Json.decodeFromString(this.getString(8)),
|
moedictDefinitions = Json.decodeFromString(this.getString(8)),
|
||||||
|
tones = Json.decodeFromString(this.getString(9)),
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun ResultSet.toListOfDictionaryEntries() = buildList {
|
private fun ResultSet.toListOfDictionaryEntries() = buildList {
|
||||||
|
@ -12,4 +12,5 @@ data class DictionaryEntry(
|
|||||||
val cedictDefinitions: List<List<String>>,
|
val cedictDefinitions: List<List<String>>,
|
||||||
val crossStraitsDefinitions: List<CrossStraitsDefinition>,
|
val crossStraitsDefinitions: List<CrossStraitsDefinition>,
|
||||||
val moedictDefinitions: List<MoedictDefinition>,
|
val moedictDefinitions: List<MoedictDefinition>,
|
||||||
|
val tones: List<Int>,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user