Skip to content

nickdanis/treemaker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

treemaker.py

About

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.

Built with

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.

Getting started

Clone the repo locally. Run the file directly:

python treemaker.py

Usage

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.

Other commands

  • show grammar Print the current grammar.
  • show category X Show all productions whose lefthand side is X.
  • add rule Prompt for a new production to be added to the grammar.
  • save grammar Saves the grammar to a file.
  • load grammar Loads a grammar from a file.
  • reset grammar Resets the grammar to the default CFG.
  • toggle latex Toggles between nltk postscript output and LaTeX qtree text output.
  • help
  • quit

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"

Contact

Nick Danis | nsdanis@wustl.edu | https://www.nickdanis.com/

About

Simple command-line tool using NLTK to parse and show syntactic trees for natural language.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages