gf_kernel
is a Jupyter kernel for the Grammatical Framework (GF) .
It allows you to write grammars and using them for parsing/translating/... all in one notebook,
which makes it great for demos and teaching, but also for small experiments with GF.
This package requires Python 3 (or newer) and this README assumes that this is the default python version.
If in doubt, use python3
instead of python
and python3 -m pip
instead of pip
.
Additionally, setuptools
is required to install this package.
This likely came with your Python distribution, but in case it did not use pip install setuptools
to install it.
If you haven't installed GF already, get it from the official download website.
For graph visualization GF uses Graphviz. Under Ubuntu etc. you can install it with
sudo apt install graphviz
or under Mac OS X with homebrew:
brew install graphviz
You can either install the kernel from the source repository:
git clone https://github.com/kwarc/gf_kernel
cd gf_kernel
pip install .
or install it directly from pip:
pip install gf-kernel
Afterwards, install the kernel module with:
python -m gf_kernel.install
You're now ready to go and can start a Jupyter notebook with:
jupyter notebook
Select the gf_kernel
as kernel in your notebook.
The kernel supports all of the GF shell commands.
Output files produced by these commands will be placed into the current directory.
The kernel can also be used to define new grammars, which are immediately imported for usage upon defining. If you would like to have line numbers for editing your code you can use the Juypter shortcut Esc+L to enable them.
In addition to the GF shell commands the kernel supports the following commands:
view
: show the graph(s) generated by the specified GF shell commandhelp
: shows the help messageexport
: saves the specified grammar in the current diretoryclean
: removes all.dot
,.png
and.gfo
files from the current directory
Here you can see a short example of how the kernel can be used. The full tutorial is available here.