A parser for the CC-CEDICT Chinese-to-English dictionary
Marvin Elsen
a176c34361
Some checks failed
Publish package / publish (push) Failing after 1m7s
Reviewed-on: #7 |
||
---|---|---|
.gitea/workflows | ||
gradle | ||
src | ||
.gitignore | ||
build.gradle.kts | ||
gradle.properties | ||
gradlew | ||
gradlew.bat | ||
LICENSE | ||
README.md | ||
settings.gradle.kts |
CC-CEDICT Parser for Kotlin
A parser for the CC-CEDICT Chinese-to-English dictionary written in Kotlin.
Build
To build the project locally, simply run the following command from the terminal:
./gradlew build
Installation
CC-CEDICT Parser for Kotlin is available from my self-hosted Gitea instance.
First, add the repository to your build.gradle.kts
file:
repositories {
maven {
url = uri("https://gitea.marvinelsen.com/api/packages/marvinelsen/maven")
}
}
Afterwards, add the package dependency to your build.gradle.kts
file:
dependencies {
implementation("com.marvinelsen:cedict-parser:2.0.0")
}
Usage
fun main() {
val cedictInputStream = GZIPInputStream(object {}.javaClass.getResourceAsStream("/cedict_1_0_ts_utf-8_mdbg.txt.gz")!!)
cedictInputStream.use {
val cedictParser = CedictParser.instance
val cedictEntries = cedictParser.parseCedict(cedictInputStream)
cedictEntries.forEach { entry ->
println(entry.traditional)
println(entry.simplified)
println(entry.pinyinSyllables.joinToString(" ") { it.format(TransliterationSystem.PINYIN_WITH_TONE_NUMBERS) })
println(entry.definitions.joinToString("/") { it.glosses.joinToString(";") })
}
}
}
License
All source code in this repository is licensed under a MIT license, unless otherwise noted.
To the following third-party code, data, and files in the repository different licenses apply:
CC-CEDICT
CC-CEDICT is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.