https://github.com/alejandro945/cyk-algorithm-server
In computer science, the Cocke–Younger–Kasami algorithm (alternatively called CYK, or CKY) is a parsing algorithm for context-free grammars published by Itiroo Sakai in 1961.
https://github.com/alejandro945/cyk-algorithm-server
cyk-algorithm rails-api ruby
Last synced: 3 months ago
JSON representation
In computer science, the Cocke–Younger–Kasami algorithm (alternatively called CYK, or CKY) is a parsing algorithm for context-free grammars published by Itiroo Sakai in 1961.
- Host: GitHub
- URL: https://github.com/alejandro945/cyk-algorithm-server
- Owner: alejandro945
- Created: 2022-10-17T03:09:41.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-07T06:08:15.000Z (over 2 years ago)
- Last Synced: 2024-12-27T02:21:35.789Z (5 months ago)
- Topics: cyk-algorithm, rails-api, ruby
- Language: Ruby
- Homepage:
- Size: 39.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://travis-ci.org/joemccann/dillinger)
# Rails CYK Rest API 🧶
## Project Setup
**Install all gems**:
```console
$ bundle install
```**Update the database with new data model**:
```console
$ rails db:migrate
```**Feed the database with default seeds**:
```console
$ rails db:seed
```**Start the web server on `http://localhost:3000` by default**:
```console
$ rails server
```**Run all RSpec tests and Rubocop**:
```console
$ rails test
```## Usage
| HTTP verbs | Paths | Used for |
| ---------- | ------ | --------:|
| POST | api/v1/responses | Determintes if w is generated by G|
| GET | api/v1/responses | List all responses - **DEPRECATED**|## Use Case Examples
### CYK Algorithm
**Boolean Output: w ∈ L(G) only if S ∈ X1n.**:
```console
$ curl -X POST -H 'Content-type: application/json' -d '{}' localhost:3000/api/v1/responses
```
#### Json Input
```json
{
"grammar": [
{
"producer": "S",
"products": ["BA", "A"]
},
{
"producer": "A",
"products": ["CA","a"]
},
{
"producer": "B",
"products": ["BB","b"]
},
{
"producer": "C",
"products": ["BA", "c"]
}
],
"word": "bca"
}
```
#### Json Output
```json
{
"id": 12,
"word": "bca",
"isAdmitted": true,
"created_at": "2022-10-18T02:14:45.389Z",
"updated_at": "2022-10-18T02:14:45.389Z"
}
```
#### New Response From Slides Example
```json
{
"response": true,
"matrix": [
[
[
"A"
],
[
[
"A"
]
],
[
[],
[
"S"
]
]
],
[
[
"A"
],
[
[
"S"
]
],
null
],
[
[
"B"
],
null,
null
]
]
}
```**Get responses in postgress database**:
```console
$ curl localhost:3000/api/v1/responses
```
#### Json Output
```json
[
{
"id": 8,
"word": "bbab",
"isAdmitted": true,
"created_at": "2022-10-18T01:50:28.200Z",
"updated_at": "2022-10-18T01:50:28.200Z"
},
{
"id": 9,
"word": "bbab",
"isAdmitted": true,
"created_at": "2022-10-18T01:53:37.901Z",
"updated_at": "2022-10-18T01:53:37.901Z"
},
{
"id": 10,
"word": "aab",
"isAdmitted": true,
"created_at": "2022-10-18T01:54:40.336Z",
"updated_at": "2022-10-18T01:54:40.336Z"
},
{
"id": 11,
"word": "aab",
"isAdmitted": true,
"created_at": "2022-10-18T01:55:11.980Z",
"updated_at": "2022-10-18T01:55:11.980Z"
},
{
"id": 12,
"word": "bca",
"isAdmitted": true,
"created_at": "2022-10-18T02:14:45.389Z",
"updated_at": "2022-10-18T02:14:45.389Z"
}
]
```