DerYeger / cyk-algorithm

Kotlin Multiplatform implementation of the CYK algorithm.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Kotlin Multiplatform implementation of the CYK algorithm.

License:MIT License


Languages

Language:Kotlin 100.0%