cedict-parser/README.md

66 lines
1.8 KiB
Markdown
Raw Normal View History

2024-09-15 13:55:19 +00:00
# CC-CEDICT Parser for Kotlin
2024-09-15 13:57:17 +00:00
A parser for the [CC-CEDICT](https://www.mdbg.net/chinese/dictionary?page=cedict) Chinese-to-English dictionary written
in [Kotlin](https://kotlinlang.org).
2024-09-15 13:55:19 +00:00
2024-09-25 18:29:48 +00:00
## Build
To build the project locally, simply run the following command from the terminal:
```sh
./gradlew build
```
2024-09-15 13:55:19 +00:00
## Installation
_CC-CEDICT Parser for Kotlin_ is available
from [my self-hosted Gitea instance](https://gitea.marvinelsen.com/marvinelsen/cedict-parser).
First, add the repository to your `build.gradle.kts` file:
```kotlin
repositories {
maven {
url = uri("https://gitea.marvinelsen.com/api/packages/marvinelsen/maven")
}
}
```
Afterwards, add the package dependency to your `build.gradle.kts` file:
```kotlin
dependencies {
2024-09-24 11:22:39 +00:00
implementation("com.marvinelsen:cedict-parser:2.0.0")
2024-09-15 13:55:19 +00:00
}
```
## Usage
```kotlin
fun main() {
2024-09-24 11:22:39 +00:00
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(";") })
}
2024-09-15 13:55:19 +00:00
}
}
```
## License
All source code in this repository is licensed under a [MIT license](LICENSE), unless otherwise noted.
To the following third-party code, data, and files in the repository different licenses apply:
### CC-CEDICT
2024-09-15 13:57:17 +00:00
[CC-CEDICT](https://cc-cedict.org/wiki) is licensed under
a [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/).