https://github.com/bl33h/cykalgorithm
This Python CYK parser demonstrates sentence parsing with a CFG in CNF.
https://github.com/bl33h/cykalgorithm
chomsky cnf-grammer cyk-algorithm cyk-parser
Last synced: 2 months ago
JSON representation
This Python CYK parser demonstrates sentence parsing with a CFG in CNF.
- Host: GitHub
- URL: https://github.com/bl33h/cykalgorithm
- Owner: bl33h
- License: mit
- Created: 2023-10-11T18:09:16.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-02T06:14:25.000Z (over 1 year ago)
- Last Synced: 2025-01-21T15:15:29.050Z (4 months ago)
- Topics: chomsky, cnf-grammer, cyk-algorithm, cyk-parser
- Language: Python
- Homepage:
- Size: 43 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cykAlgorithm
This CYK (Cocke-Younger-Kasami) parser is a Python program that demonstrates parsing a sentence using a Context-Free Grammar (CFG) represented in Chomsky Normal Form (CNF). It utilizes the provided Python files and a JSON configuration file to perform the parsing. The CNF conversion is done by the `CNFConverter` class in `chomsky.py`, and the CYK parsing is performed in `cyk.py`.## Files
- `main.py`: The main Python script that loads the CFG from the `input.json` file, converts it to CNF, and then performs CYK parsing on a sample sentence.
- `chomsky.py`: The Python module responsible for the CNF conversion of the provided CFG.
- `cyk.py`: The Python module that implements the CYK parsing algorithm.
- `input.json`: The JSON configuration file containing the CFG in CNF format.## How to Use
To run the CYK parser for the given CFG, follow these steps:
1. Clone this repository to your local machine:```bash
git clone https://github.com/bl33h/CYK-Parser
cd src
python main.py