This is a simple command-line interface for the tree parsing and drawing tools in the nltk package. It is intended for instructors of and students in linguistics classes.
If you do not have nltk installed, you will also need to download additional data after installing the python module. The nltk-book option is sufficient.
Clone the repo locally. Run the file directly:
python treemaker.py
By default, a basic context-free grammar based on the grammar from Language Files 12 is initialized, with an additional lexicon of terminals. Typing any sentence will display the trees for that sentence if they exist, and it will ask to learn any new words if they are not known.
show grammarPrint the current grammar.show category XShow all productions whose lefthand side is X.add rulePrompt for a new production to be added to the grammar.save grammarSaves the grammar to a file.load grammarLoads a grammar from a file.reset grammarResets the grammar to the default CFG.toggle latexToggles between nltk postscript output and LaTeX qtree text output.helpquit
The format of the productions and grammars should follow that as those accepted by the nltk.CFG.fromstring function as described here and demonstrated below:
S -> NP VP
NP -> "cats" | "dogs"
VP -> "sleep"
Nick Danis | nsdanis@wustl.edu | https://www.nickdanis.com/