Giter Site home page Giter Site logo

cfg-parse's Introduction

Exploring Effective Parsing of Context-Free Grammars

My CSCI 256: Algorithm Design & Analysis final project. Here, I explore CFG parsers, implementing a depth-first search parser, an Earley parser, and a CYK parser.

Paper

The paper writeup can be found here.

Implementation

Main files of interest:

  • DParser.java
  • CYK.java
  • Earley.java

Test files can be found in the test_files directory:

  • short.txt
  • medium.txt
  • long.txt
  • longer.txt
  • longest.txt
  • stress0.txt
  • stress1.txt
  • recursive.txt
  • simple.txt
  • haiku.txt

The main test files are essentially the same grammar, with a lengthened start rule to generate longer input strings. All the grammars other than simple.txt and recursive.txt have been adapted from Steve Freund's grammars.

To run the same tests as presented in the paper:

  1. compile all with: javac *.java
  2. run with: java Test "numTrials" "testFile"

Notes

DFS will not terminate on recursive.txt, and will not terminate for a very long time on stress0.txt and stress1.txt.

Try as I might, I could not get CYK to run in a reasonable amount of time on anything other than simple.txt and haiku.txt. It may be because my CNF class converts grammars inefficiently, but efficient conversion of CFGs to Chomsky Normal Form is another research topic in itself. So, I leave the CYK implementation here for viewing purposes, but Test.java does not run CYK when performing its tests.

cfg-parse's People

Contributors

tliutony avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.