TL;DR The repository implements the generalized left-corner transformation from our EMNLP 2023 paper and many other utilities for working with context-free grammars.
Abstract: The left-corner transformation is used to remove left recursion from context-free grammars, which is an important step towards making the grammar parsable top-down with simple techniques. This paper generalizes prior left-corner transformations to support semiring-weighted production rules and to provide finer-grained control over which left corners may be moved. Our generalized left-corner transformation (GLCT) arose from unifying the left-corner transformation and speculation transformation, originally for logic programming. Our new transformation and speculation define equivalent weighted languages. Yet, their derivation trees are structurally different in an important way: GLCT replaces left recursion with right recursion, and speculation does not. We also provide several technical results regarding the formal relationships between the outputs of GLCT, speculation, and the original grammar. Lastly, we empirically investigate the efficiency of GLCT for left-recursion elimination from grammars of nine languages.
Option 1: pip
$ pip install leftcorner
Option 2: Clone and install the development version
$ git clone [email protected]:rycolab/left-corner.git ./left-corner
$ cd left-corner
$ pip install -e .
Please see the tutorial notebook (Tutorial.ipynb).
Unit and integration tests
$ pytest tests/tests.py
Code coverage
$ ./run-coverage.bash
The experiments on the English ATIS grammar can be run without downloading additional data. To run the experiments on the non-English, SPMRL grammars, you will need to acquire the SPRML treebanks from the shared task website.
$ python test/test_grammars.py
If you use this repository in your work, please link to it or cite it with the following BibTeX:
@inproceedings{opedal-etal-2023-exploration,
title = "An Exploration of Left-Corner Transformations",
author = "Opedal, Andreas and
Tsipidi, Eleftheria and
Pimentel, Tiago and
Cotterell, Ryan and
Vieira, Tim",
booktitle = "Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing",
month = dec,
year = "2023",
address = "Singapore",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2023.emnlp-main.827",
pages = "13393--13427",
}