https://github.com/mrmike/cyk
Implementation of CYK - Cocke–Younger–Kasami algorithm.
https://github.com/mrmike/cyk
Last synced: about 1 year ago
JSON representation
Implementation of CYK - Cocke–Younger–Kasami algorithm.
- Host: GitHub
- URL: https://github.com/mrmike/cyk
- Owner: mrmike
- Created: 2014-06-04T07:50:43.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-06-04T08:10:35.000Z (about 12 years ago)
- Last Synced: 2025-04-06T04:17:01.327Z (over 1 year ago)
- Language: Ruby
- Size: 129 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
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 | | | | | | |
+---+-----+------+-----+------+------+-----+------+
```