Skip to content

thinkzhou/PCFG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

Implementation of algorithms in PCFG

What is it

Implementation of the Expectation Maximation algorithm to calculate probabilities of rules in Context-Free Grammar (CFG) in order to create Probabilistic Context-Free Grammar (PCFG). It also generates new sentences in that grammar using a PCFG (.gen file).

What do you need to run it

  • .cfg file

A file with a context-free grammar in Chomsky normal form, but with "#" instead of an arrow (no spaces around).

Rule example:

S#NPa ViADV
  • .train file

A text file with .train extension with sentences you want to train your grammar on. Sentences should be in separate lines.

How to run it

In the command line, type:

python train.py [YOUR_GRAMMAR_FILE].cfg [YOUR_TRAIN_FILE].train

You can use some examples in the test folder, or try your own.

References

About

implementation of algorithms in PCFG

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages