Skip to content

kkdai/cyk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CYK: Cocke–Younger–Kasami algorithm in Golang

GitHub license GoDoc Build Status

What is this CYK Algoritgm

In computer science, the Cocke–Younger–Kasami algorithm (alternatively called CYK, or CKY) is a parsing algorithm for context-free grammars, named after its inventors, John Cocke, Daniel Younger and Tadao Kasami. It employs bottom-up parsing and dynamic programming.

The standard version of CYK operates only on context-free grammars given in Chomsky normal form (CNF). However any context-free grammar may be transformed to a CNF grammar expressing the same language

Installation and Usage

Install

go get github.com/kkdai/cyk

Usage

Following is sample code to implement a epsilon-NFA automata diagram as follow:

package main

import (
    "github.com/kkdai/cyk"
)

func main() {
	cyk := NewCYK("S")
	cyk.InputGrammar("S", "AB")
	cyk.InputGrammar("A", "BC")
	cyk.InputGrammar("B", "AC")
	cyk.InputGrammar("A", "a")
	cyk.InputGrammar("B", "b")
	cyk.InputGrammar("C", "a")
	cyk.InputGrammar("C", "b")

	//Should be false, fianl result is {A}
	result := cyk.Eval("ababa")
	fmt.Println("Result:", result)
	cyk.PrintResult()
}

Inspired By

Project52

It is one of my project 52.

License

This package is licensed under MIT license. See LICENSE for details.

About

CYK algorithm in Golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages