Compare commits

...

3 Commits

Author SHA1 Message Date
a176c34361 Merge pull request 'Update README' (#7) from update-versions into main
Some checks failed
Publish package / publish (push) Failing after 1m7s
Reviewed-on: #7
2024-09-25 18:32:25 +00:00
d8d9ee7939
Add build section
All checks were successful
Pull Request / build (pull_request) Successful in 1m42s
2024-09-25 20:29:48 +02:00
c95d167456
Update README
All checks were successful
Pull Request / build (pull_request) Successful in 2m16s
2024-09-24 13:22:39 +02:00

View File

@ -3,6 +3,14 @@
A parser for the [CC-CEDICT](https://www.mdbg.net/chinese/dictionary?page=cedict) Chinese-to-English dictionary written A parser for the [CC-CEDICT](https://www.mdbg.net/chinese/dictionary?page=cedict) Chinese-to-English dictionary written
in [Kotlin](https://kotlinlang.org). in [Kotlin](https://kotlinlang.org).
## Build
To build the project locally, simply run the following command from the terminal:
```sh
./gradlew build
```
## Installation ## Installation
_CC-CEDICT Parser for Kotlin_ is available _CC-CEDICT Parser for Kotlin_ is available
@ -22,7 +30,7 @@ Afterwards, add the package dependency to your `build.gradle.kts` file:
```kotlin ```kotlin
dependencies { dependencies {
implementation("com.marvinelsen:cedict-parser:1.0-SNAPSHOT") implementation("com.marvinelsen:cedict-parser:2.0.0")
} }
``` ```
@ -30,19 +38,20 @@ dependencies {
```kotlin ```kotlin
fun main() { fun main() {
val cedictInputStream = val cedictInputStream = GZIPInputStream(object {}.javaClass.getResourceAsStream("/cedict_1_0_ts_utf-8_mdbg.txt.gz")!!)
GZIPInputStream(object {}.javaClass.getResourceAsStream("/cedict_1_0_ts_utf-8_mdbg.txt.gz")!!)
cedictInputStream.use {
val cedictParser = CedictParser.instance val cedictParser = CedictParser.instance
val cedictEntries = cedictParser.parseCedict(cedictInputStream) val cedictEntries = cedictParser.parseCedict(cedictInputStream)
for (entry in cedictEntries) { cedictEntries.forEach { entry ->
println(entry.traditional) println(entry.traditional)
println(entry.simplified) println(entry.simplified)
println(entry.pinyinSyllables.joinToString(" ")) println(entry.pinyinSyllables.joinToString(" ") { it.format(TransliterationSystem.PINYIN_WITH_TONE_NUMBERS) })
println(entry.definitions.joinToString("/") { it.glosses.joinToString(";") }) println(entry.definitions.joinToString("/") { it.glosses.joinToString(";") })
} }
} }
}
``` ```
## License ## License