Skip to content

Kotlin Multiplatform implementation of the CYK algorithm.

License

Notifications You must be signed in to change notification settings

DerYeger/cyk-algorithm

Repository files navigation

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.

Credits

Logo by Magdalena Jirku.