Git Product home page Git Product logo

pcfg_cky_nlu's Introduction

PCFG and CKY Parser

E1-246 2019: Assignment 3

Usage:

Install needed packages from requirements.txt.
Download treebank:

    import nltk
    nltk.download('treebank')

python pcfg_grammar.py train        Start training model for generating PCFG, generated grammar is saved in 'grammar.pickl' in same directory.

python pcfg_grammar.py evaluate     Grammar in 'grammar.pickl' is evaluated on test dataset, Precision, Recall and F1 score metrics are reported. 
                 
python pcfg_grammar.py test 'your_sentence'     creates and prints a parse tree for given sentence using grammar saved in 'grammar.pickl'. 

Trained Model:

Trained model (PCFG Grammar) can be downloaded from: https://drive.google.com/open?id=1ciamamWs6XDXhdCeGZ3tEBUtj59ypY13

File Descriptions:

cky_parser.py       contains CKY parser implementation.
pcfg_grammar.py     contains driver code and pcfg estimation.
grammar.pickl       saved pcfg grammar.

References:

https://en.wikipedia.org/wiki/Probabilistic_context-free_grammar

https://en.wikipedia.org/wiki/Chomsky_normal_form

https://www.nltk.org/_modules/nltk/parse/viterbi.html

http://www.nltk.org/howto/corpus.html

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.