{"id":18331298,"url":"https://github.com/mynttt/cyk-algorithm","last_synced_at":"2025-04-06T02:30:59.740Z","repository":{"id":65736373,"uuid":"119007788","full_name":"mynttt/CYK-algorithm","owner":"mynttt","description":"Java implementation of the CYK algorithm.","archived":false,"fork":false,"pushed_at":"2020-02-26T01:07:36.000Z","size":18,"stargazers_count":10,"open_issues_count":0,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-05-20T18:56:00.323Z","etag":null,"topics":["automata-theory","cyk-algorithm","java","theoretical-computer-science"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mynttt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-26T05:03:55.000Z","updated_at":"2024-05-06T13:07:35.000Z","dependencies_parsed_at":"2023-02-07T10:25:10.548Z","dependency_job_id":null,"html_url":"https://github.com/mynttt/CYK-algorithm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mynttt%2FCYK-algorithm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mynttt%2FCYK-algorithm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mynttt%2FCYK-algorithm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mynttt%2FCYK-algorithm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mynttt","download_url":"https://codeload.github.com/mynttt/CYK-algorithm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223232642,"owners_count":17110487,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automata-theory","cyk-algorithm","java","theoretical-computer-science"],"created_at":"2024-11-05T19:29:46.143Z","updated_at":"2025-04-06T02:30:59.732Z","avatar_url":"https://github.com/mynttt.png","language":"Java","readme":"# CYK Algorithm\n\n## A Java implementation of the CYK-Algorithm.\n\nThe CYK-Algorithm can be used to check if a word can be derived from a CFG (context-free grammar).\n\nYou only need your grammar to be in the CNF (Chomsky normal form) format. This Java application will parse an external grammar file and then output the result visualized in a table.\n\n## Grammar File\n\nA grammar file will have the following structure.\n\n```\nS                             -\u003e Starting Symbol\na b                           -\u003e Terminals\nS A B E C X Y Z               -\u003e Non-Terminals\nS YB XA *                     -\u003e 4th and all following lines are production rules\nE YB XA                       -\u003e You can add multiple rules from one terminal by seperating via whitespace\nA a YE XC                     -\u003e This reads as A -\u003e a | YE | XC\nB b XE YZ\nC AA\nX b\nY a\nZ BB\n\nFor a token terminal, simply add the token like a normal terminal. \nFor example Y token will be parsed as Y -\u003e token.\n```\n\nAfter you compiled the .java file you can simply run it via\n\n```\njava CYK \u003cGrammarFile\u003e \u003cWord\u003e\n```\n\nSample output for the supplied grammar above using the word abbabaa:\n\n```\n$ java CYK grammar.txt abbbabaa\nWord: abbbabaa\n\nG = ({a, b}, {S, A, B, E, C, X, Y, Z}, P, S)\n\nWith Productions P as:\nA -\u003e a | YE | XC\nB -\u003e b | XE | YZ\nC -\u003e AA\nE -\u003e YB | XA\nS -\u003e YB | XA | *\nX -\u003e b\nY -\u003e a\nZ -\u003e BB\n\nApplying CYK-Algorithm:\n\n+-------+-------+-------+-------+-------+-------+-------+-------+\n| a     | b     | b     | b     | a     | b     | a     | a     |\n+-------+-------+-------+-------+-------+-------+-------+-------+\n| A,Y   | B,X   | B,X   | B,X   | A,Y   | B,X   | A,Y   | A,Y   |\n+-------+-------+-------+-------+-------+-------+-------+-------+\n| E,S   | Z     | Z     | E,S   | E,S   | E,S   | C     |\n+-------+-------+-------+-------+-------+-------+-------+\n| B     | -     | B     | B     | A     | A     |\n+-------+-------+-------+-------+-------+-------+\n| Z     | Z     | Z     | E,S   | C     |\n+-------+-------+-------+-------+-------+\n| B     | -     | B     | A     |\n+-------+-------+-------+-------+\n| Z     | Z     | E,S   |\n+-------+-------+-------+\n| B     | B     |\n+-------+-------+\n| E,S   |\n+-------+\n\nThe word abbbabaa is an element of the CFG G and can be derived from it.\n```\n## Grammars with token words\n\nThis application also supports token words, that means you define a terminal as a whole string. The token detection gets triggered automatically once you pass more than two arguments. Sample output below.\n\n```\n$ java CYK test.txt test is a test\nWord: test is a test\n\nG = ({this, is, a, test}, {S, A, B, E, C, X, Y, Z}, P, S)\n\nWith Productions P as:\nA -\u003e this | YE | XC\nB -\u003e is | XE | YZ\nC -\u003e AA\nE -\u003e YB | XA\nS -\u003e YB | XA | *\nX -\u003e a\nY -\u003e test\nZ -\u003e BB\n\nApplying CYK-Algorithm:\n\n+--------+--------+--------+--------+\n| test   | is     | a      | test   |\n+--------+--------+--------+--------+\n| Y      | B      | X      | Y      |\n+--------+--------+--------+--------+\n| E,S    | -      | -      |\n+--------+--------+--------+\n| -      | -      |\n+--------+--------+\n| -      |\n+--------+\n\nThe word \"test is a test\" is not an element of the CFG G and can not be derived from it.\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmynttt%2Fcyk-algorithm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmynttt%2Fcyk-algorithm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmynttt%2Fcyk-algorithm/lists"}