Skip to content

mrmike/cyk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CYK Algorithm

Project goal was to implement Cocke–Younger–Kasami algorithm. For more info take a look at http://en.wikipedia.org/wiki/CYK_algorithm.

Installation

In project main folder run following command

$ bundle install

and that's all.

Grammar and lexicon

Before first usage add your grammar rules to app/data/grammar.txt file, e.g.

S -> NP VP
VP -> VP PP
VP -> V NP
PP -> P NP
NP -> DET N

You need to add word for your lexicon as well, to do that edit app/data/lexicon.txt file, e.g.

NP -> she
V -> eats
P -> with
N -> fish
N -> fork
DET -> a

Usage

To run algorithm simply ruby app.rb file in app/ folder with given sentence as a input.

$ cd app/
$ ruby app.rb < input.txt

Result

Result is given in table form

+---+-----+------+-----+------+------+-----+------+
|   | she | eats |  a  | fish | with |  a  | fork |
+---+-----+------+-----+------+------+-----+------+
| 1 | NP  | V    | DET | N    | P    | DET | N    |
| 2 |     |      | NP  |      |      | NP  |      |
| 3 |     | VP   |     |      | PP   |     |      |
| 4 | S   |      |     |      |      |     |      |
| 5 |     |      |     |      |      |     |      |
| 6 |     | VP   |     |      |      |     |      |
| 7 | S   |      |     |      |      |     |      |
+---+-----+------+-----+------+------+-----+------+

About

Implementation of CYK - Cocke–Younger–Kasami algorithm.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages