cross-straits-parser/README.md

70 lines
2.2 KiB
Markdown
Raw Normal View History

2024-10-09 16:07:08 +00:00
# Cross-straits (兩岸詞典) Parser for Kotlin
A parser for the [Cross-straits (兩岸詞典)](https://github.com/g0v/moedict-data-csld) Chinese-to-Chinese dictionary
written
in [Kotlin](https://kotlinlang.org).
## Build
To build the project locally, simply run the following command from the terminal:
```sh
./gradlew build
```
## Installation
_Cross-straits (兩岸詞典) 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-10-09 16:20:19 +00:00
implementation("com.marvinelsen:cross-straits-parser:1.0.1")
2024-10-09 16:07:08 +00:00
}
```
## Usage
```kotlin
fun main() {
val crossStraitsInputStream = GZIPInputStream(object {}.javaClass.getResourceAsStream("/cross-straits.csv.gz")!!)
crossStraitsInputStream.use {
val crossStraitsParser = CrossStraitsParser.instance
val crossStraitsEntries = crossStraitsParser.parse(crossStraitsInputStream)
crossStraitsEntries.forEach { entry ->
println(entry.traditional)
println(entry.simplified)
println(entry.pronunciationTaiwan.joinToString(" ") { it.format(TransliterationSystem.PINYIN_WITH_TONE_NUMBERS) })
println(entry.pronunciationMainland.joinToString(" ") { it.format(TransliterationSystem.PINYIN_WITH_TONE_NUMBERS) })
println(entry.definitions.first().definition)
println(entry.definitions.first().examples)
}
}
}
```
## 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:
2024-10-09 16:20:19 +00:00
### Cross-straits (兩岸詞典) Dictionary
2024-10-09 16:07:08 +00:00
2024-10-09 16:20:19 +00:00
[Cross-Straits Dictionary (兩岸詞典)](https://github.com/g0v/moedict-data-csld) provided by
the [中華文化總會](https://www.gacc.org.tw) is licensed under
a [CC BY-NC-ND 3.0 TW](https://creativecommons.org/licenses/by-nc-nd/3.0/tw/).