Probabilistic Grammar Compiler

NLP, Python

Hover for a Poem. Click to Resize.


Description

A tool enabling the construction of context-sensitive grammars while incorporating custom probabilities for rule application. Notably, it ensures that the resulting grammar remains well-typed by preserving typing. This feature is crucial as it guarantees that the generated language adheres to specified type constraints, promoting correctness and coherence in the generated structures. The compiler also lets you define grammar rules with associated probabilities, allowing for fine-grained control over the generation process.

Grammar Classification

The grammar hierarchy encompasses different levels of formal grammars, starting with regular grammars that generate regular languages, followed by context-free grammars that generate context-free languages with nested structures, and then context-sensitive grammars that handle context-dependent rewriting. At the highest level, recursive enumerable grammars, also known as Turing machine grammars, generate recursively enumerable languages, exhibiting unbounded rewriting and the ability to express complex and undecidable languages.

Recursive Enumerable

Context-Sensitive

Context-Free

Regular

Contributions

I wrote the SensitiveProduction class of the library. This is the portion of the library meant for handling context-sensitive grammar productions.