Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/deryeger/cyk-algorithm

Kotlin Multiplatform implementation of the CYK algorithm.
https://github.com/deryeger/cyk-algorithm

cyk-algorithm kotlin-library kotlin-multiplatform

Last synced: about 2 months ago
JSON representation

Kotlin Multiplatform implementation of the CYK algorithm.

Awesome Lists containing this project

README

        

# CYK Algorithm


License
Build
Download

> Kotlin Multiplatform implementation of the CYK algorithm.

## Installation

#### build.gradle.kts

```
repositories {
maven(url = "https://dl.bintray.com/deryeger/maven")
}

dependencies {
implementation("eu.yeger:cyk-algorithm:0.2.0")
}
```

## Usage

This library contains two variants of the algorithm.
Both versions can be used by providing a grammar to the included parser or by programmatically generating the required model.
While the first version only computes the end result, `runningCYK` computes a list containing every step of the algorithm.

```
cyk("hello world") {
grammar("S") {
"""
S -> A B
A -> hello
B -> world
""".trimIndent()
}
}.getOrElse { error(it) }

runningCYK("hello world") {
grammar("S") {
"""
S -> A B
A -> hello
B -> world
""".trimIndent()
}
}.getOrElse { error(it) }
```

## Example

An example project using this library can be found [here](https://github.com/DerYeger/cyk-visualizer).

## Credits

Logo by [Magdalena Jirku](https://www.deviantart.com/keshyx).